[895] in BarnOwl Developers
[D-O-H] r882 - in branches/barnowl_unicode: . owl owl/perl/modules/IRC/lib/BarnOwl/Message owl/perl/modules/IRC/lib/BarnOwl/Module owl/perl/modules/IRC/lib/BarnOwl/Module/IRC owl/perl/modules/Jabber/lib/BarnOwl/Module
daemon@ATHENA.MIT.EDU (asedeno@MIT.EDU)
Thu Oct 29 18:10:53 2009
Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
To: dirty-owl-hackers@mit.edu
From: asedeno@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Date: Wed, 16 Jan 2008 13:46:38 -0500 (EST)
Author: asedeno
Date: 2008-01-16 13:46:37 -0500 (Wed, 16 Jan 2008)
New Revision: 882
Modified:
branches/barnowl_unicode/
branches/barnowl_unicode/owl/README
branches/barnowl_unicode/owl/editwin.c
branches/barnowl_unicode/owl/owl.c
branches/barnowl_unicode/owl/perl/modules/IRC/lib/BarnOwl/Message/IRC.pm
branches/barnowl_unicode/owl/perl/modules/IRC/lib/BarnOwl/Module/IRC.pm
branches/barnowl_unicode/owl/perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm
branches/barnowl_unicode/owl/perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm
branches/barnowl_unicode/owl/perlconfig.c
branches/barnowl_unicode/owl/perlwrap.pm
branches/barnowl_unicode/owl/stylefunc.c
Log:
Merged revisions 847-881 via svnmerge from
file:///afs/sipb.mit.edu/project/barnowl/src/svn/trunk
........
r848 | nelhage | 2008-01-12 02:00:53 -0500 (Sat, 12 Jan 2008) | 2 lines
Adding a note about IRC deps
........
r853 | asedeno | 2008-01-12 11:56:20 -0500 (Sat, 12 Jan 2008) | 2 lines
Fixing a pet peeve.
Clearing the line should preserve the echochar.
........
r854 | asedeno | 2008-01-12 15:07:20 -0500 (Sat, 12 Jan 2008) | 3 lines
Jabber -
* fix logins to jabber.org - reported by gendalia
........
r860 | nelhage | 2008-01-13 18:08:14 -0500 (Sun, 13 Jan 2008) | 2 lines
Kill a uninitialized warning
........
r861 | nelhage | 2008-01-13 18:10:13 -0500 (Sun, 13 Jan 2008) | 1 line
Show JOIN and PART for login/outs
........
r862 | nelhage | 2008-01-13 18:10:44 -0500 (Sun, 13 Jan 2008) | 1 line
'motd' is a method of Net::IRC::Connection, don't clobber it
........
r863 | nelhage | 2008-01-13 22:08:52 -0500 (Sun, 13 Jan 2008) | 2 lines
Don't clober our parent's connected() method, either.
........
r864 | nelhage | 2008-01-14 00:24:43 -0500 (Mon, 14 Jan 2008) | 3 lines
Right, _connected doesn't work either. I think I need to refactor this
to not be a subclass...
........
r875 | nelhage | 2008-01-15 14:40:02 -0500 (Tue, 15 Jan 2008) | 2 lines
Actually free the right thing when freeing perl commands
........
r881 | nelhage | 2008-01-16 02:59:06 -0500 (Wed, 16 Jan 2008) | 1 line
Move oneline style to perl. closes 43
........
Property changes on: branches/barnowl_unicode
___________________________________________________________________
Name: svnmerge-integrated
- /trunk:1-846
+ /trunk:1-881
Modified: branches/barnowl_unicode/owl/README
===================================================================
--- branches/barnowl_unicode/owl/README 2008-01-16 07:59:06 UTC (rev 881)
+++ branches/barnowl_unicode/owl/README 2008-01-16 18:46:37 UTC (rev 882)
@@ -27,3 +27,8 @@
(Note that these are all available as Debian packages)
We plan to soon add targets to the Makefile to check for and install
these for you.
+
+The IRC module requires:
+
+Net::IRC
+Class::Accessor
Modified: branches/barnowl_unicode/owl/editwin.c
===================================================================
--- branches/barnowl_unicode/owl/editwin.c 2008-01-16 07:59:06 UTC (rev 881)
+++ branches/barnowl_unicode/owl/editwin.c 2008-01-16 18:46:37 UTC (rev 882)
@@ -197,6 +197,7 @@
int lock;
int dotsend=e->dotsend;
char *locktext=NULL;
+ char echochar=e->echochar;
lock=0;
if (e->lock > 0) {
@@ -216,6 +217,9 @@
if (dotsend) {
owl_editwin_set_dotsend(e);
}
+ if (echochar) {
+ owl_editwin_set_echochar(e, echochar);
+ }
if (locktext) owl_free(locktext);
owl_editwin_adjust_for_locktext(e);
Modified: branches/barnowl_unicode/owl/owl.c
===================================================================
--- branches/barnowl_unicode/owl/owl.c 2008-01-16 07:59:06 UTC (rev 881)
+++ branches/barnowl_unicode/owl/owl.c 2008-01-16 18:46:37 UTC (rev 882)
@@ -261,9 +261,6 @@
s=owl_malloc(sizeof(owl_style));
owl_style_create_internal(s, "basic", &owl_stylefunc_basic, "Basic message formatting.");
owl_global_add_style(&g, s);
- s=owl_malloc(sizeof(owl_style));
- owl_style_create_internal(s, "oneline", &owl_stylefunc_oneline, "Formats for one-line-per-message");
- owl_global_add_style(&g, s);
/* setup the default filters */
/* the personal filter will need to change again when AIM chat's are
Modified: branches/barnowl_unicode/owl/perl/modules/IRC/lib/BarnOwl/Message/IRC.pm
===================================================================
--- branches/barnowl_unicode/owl/perl/modules/IRC/lib/BarnOwl/Message/IRC.pm 2008-01-16 07:59:06 UTC (rev 881)
+++ branches/barnowl_unicode/owl/perl/modules/IRC/lib/BarnOwl/Message/IRC.pm 2008-01-16 18:46:37 UTC (rev 882)
@@ -55,6 +55,11 @@
sub long_sender {shift->{from} || ""};
+sub login_type {
+ my $self = shift;
+ return " (" . ($self->is_login ? "JOIN" : "PART") . ")";
+}
+
sub login_extra { shift->channel; }
Modified: branches/barnowl_unicode/owl/perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm
===================================================================
--- branches/barnowl_unicode/owl/perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm 2008-01-16 07:59:06 UTC (rev 881)
+++ branches/barnowl_unicode/owl/perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm 2008-01-16 18:46:37 UTC (rev 882)
@@ -15,7 +15,7 @@
=cut
use base qw(Net::IRC::Connection Class::Accessor Exporter);
-__PACKAGE__->mk_accessors(qw(alias channels motd));
+__PACKAGE__->mk_accessors(qw(alias channels owl_connected owl_motd));
our @EXPORT_OK = qw(&is_private);
use BarnOwl;
@@ -28,11 +28,11 @@
my $self = $class->SUPER::new($irc, %args);
$self->alias($alias);
$self->channels([]);
- $self->motd("");
+ $self->owl_motd("");
+ $self->owl_connected(0);
bless($self, $class);
$self->add_default_handler(sub { goto &on_event; });
- $self->add_handler(376 => sub { goto &on_connect });
$self->add_handler(['msg', 'notice', 'public', 'caction'],
sub { goto &on_msg });
$self->add_handler(['welcome', 'yourhost', 'created',
@@ -57,11 +57,6 @@
############################### IRC callbacks ##################################
################################################################################
-sub on_connect {
- my ($self, $evt) = @_;
- BarnOwl::admin_message("IRC", "Connected to " . $self->server . " (" . $self->alias . ")");
-}
-
sub new_message {
my $self = shift;
my $evt = shift;
@@ -114,20 +109,26 @@
sub on_motdstart {
my ($self, $evt) = @_;
- $self->motd(join "\n", cdr $evt->args);
+ $self->owl_motd(join "\n", cdr $evt->args);
}
sub on_motd {
my ($self, $evt) = @_;
- $self->motd(join "\n", $self->motd, cdr $evt->args);
+ $self->owl_motd(join "\n", $self->owl_motd, cdr $evt->args);
}
sub on_endofmotd {
my ($self, $evt) = @_;
- $self->motd(join "\n", $self->motd, cdr $evt->args);
+ $self->owl_motd(join "\n", $self->owl_motd, cdr $evt->args);
+ if(!$self->owl_connected) {
+ BarnOwl::admin_message("IRC", "Connected to " .
+ $self->server . " (" . $self->alias . ")");
+ $self->owl_connected(1);
+
+ }
BarnOwl::admin_message("IRC",
- BarnOwl::Style::boldify('MOTD for ' . $evt->alias) . "\n"
- . strip_irc_formatting($self->motd));
+ BarnOwl::Style::boldify('MOTD for ' . $self->alias) . "\n"
+ . strip_irc_formatting($self->owl_motd));
}
sub on_join {
@@ -161,6 +162,9 @@
BarnOwl::admin_message("IRC",
"[" . $self->alias . "] " .
[$evt->args]->[1] . ": Nick already in use");
+ unless($self->owl_connected) {
+ $self->disconnect;
+ }
}
sub on_event {
Modified: branches/barnowl_unicode/owl/perl/modules/IRC/lib/BarnOwl/Module/IRC.pm
===================================================================
--- branches/barnowl_unicode/owl/perl/modules/IRC/lib/BarnOwl/Module/IRC.pm 2008-01-16 07:59:06 UTC (rev 881)
+++ branches/barnowl_unicode/owl/perl/modules/IRC/lib/BarnOwl/Module/IRC.pm 2008-01-16 18:46:37 UTC (rev 882)
@@ -103,6 +103,7 @@
BarnOwl::new_command('irc-nick' => \&cmd_nick);
BarnOwl::new_command('irc-names' => \&cmd_names);
BarnOwl::new_command('irc-whois' => \&cmd_whois);
+ BarnOwl::new_command('irc-motd' => \&cmd_motd);
}
$BarnOwl::Hooks::startup->add(\&startup);
@@ -244,6 +245,12 @@
$conn->whois($who);
}
+sub cmd_motd {
+ my $cmd = shift;
+ my $conn = get_connection(\@_);
+ $conn->motd;
+}
+
################################################################################
########################### Utilities/Helpers ##################################
################################################################################
@@ -255,7 +262,8 @@
return get_connection_by_alias(shift @$args);
}
my $channel = $args->[-1];
- if ($channel =~ /^#/ and $channels{$channel} and @{$channels{$channel}} == 1) {
+ if (defined($channel) && $channel =~ /^#/
+ and $channels{$channel} and @{$channels{$channel}} == 1) {
return $channels{$channel}[0];
}
my $m = BarnOwl::getcurmsg();
Modified: branches/barnowl_unicode/owl/perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm
===================================================================
--- branches/barnowl_unicode/owl/perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm 2008-01-16 07:59:06 UTC (rev 881)
+++ branches/barnowl_unicode/owl/perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm 2008-01-16 18:46:37 UTC (rev 882)
@@ -369,7 +369,7 @@
my @result = $client->AuthSend( %{ $vars{jlogin_authhash} } );
if ( !@result || $result[0] ne 'ok' ) {
- if ( !$vars{jlogin_havepass} && ( !@result || $result[0] eq '401' ) ) {
+ if ( !$vars{jlogin_havepass} && ( !@result || $result[0] eq '401' || $result[0] eq 'error') ) {
$vars{jlogin_havepass} = 1;
$conn->removeConnection($jidStr);
BarnOwl::start_password( "Password for $jidStr: ", \&do_login );
Modified: branches/barnowl_unicode/owl/perlconfig.c
===================================================================
--- branches/barnowl_unicode/owl/perlconfig.c 2008-01-16 07:59:06 UTC (rev 881)
+++ branches/barnowl_unicode/owl/perlconfig.c 2008-01-16 18:46:37 UTC (rev 882)
@@ -481,7 +481,7 @@
void owl_perlconfig_cmd_free(owl_cmd *cmd)
{
- SvREFCNT_dec(cmd);
+ SvREFCNT_dec(cmd->cmd_perl);
}
void owl_perlconfig_edit_callback(owl_editwin *e)
Modified: branches/barnowl_unicode/owl/perlwrap.pm
===================================================================
--- branches/barnowl_unicode/owl/perlwrap.pm 2008-01-16 07:59:06 UTC (rev 881)
+++ branches/barnowl_unicode/owl/perlwrap.pm 2008-01-16 18:46:37 UTC (rev 882)
@@ -830,11 +830,111 @@
# replace newline followed by anything with
# newline plus four spaces and that thing.
$body =~ s/\n(.)/\n $1/g;
-
+ # Trim trailing newlines.
+ $body =~ s/\n*$//;
return " ".$body;
}
+package BarnOwl::Style::OneLine;
+################################################################################
+# Branching point for various formatting functions in this style.
+################################################################################
+use constant BASE_FORMAT => '%s %-13.13s %-11.11s %-12.12s ';
+sub format_message($) {
+ my $m = shift;
+# if ( $m->is_zephyr ) {
+# return format_zephyr($m);
+# }
+ if ( $m->is_login ) {
+ return format_login($m);
+ }
+ elsif ( $m->is_ping) {
+ return format_ping($m);
+ }
+ elsif ( $m->is_admin || $m->is_loopback) {
+ return format_local($m);
+ }
+ else {
+ return format_chat($m);
+ }
+}
+
+BarnOwl::_create_style("oneline", "BarnOwl::Style::OneLine::format_message", "Formats for one-line-per-message");
+
+################################################################################
+
+sub format_login($) {
+ my $m = shift;
+ return sprintf(
+ BASE_FORMAT,
+ '<',
+ $m->type,
+ uc( $m->login ),
+ $m->pretty_sender)
+ . ($m->login_extra ? "at ".$m->login_extra : '');
+}
+
+sub format_ping($) {
+ my $m = shift;
+ return sprintf(
+ BASE_FORMAT,
+ '<',
+ $m->type,
+ 'PING',
+ $m->pretty_sender)
+}
+
+sub format_chat($)
+{
+ my $m = shift;
+ my $dir = lc($m->{direction});
+ my $dirsym = '-';
+ if ($dir eq 'in') {
+ $dirsym = '<';
+ }
+ elsif ($dir eq 'out') {
+ $dirsym = '>';
+ }
+
+ my $line;
+ if ($m->is_personal) {
+ $line= sprintf(BASE_FORMAT,
+ $dirsym,
+ $m->type,
+ '',
+ ($dir eq 'out'
+ ? $m->pretty_recipient
+ : $m->pretty_sender));
+ }
+ else {
+ $line = sprintf(BASE_FORMAT,
+ $dirsym,
+ $m->context,
+ $m->subcontext,
+ ($dir eq 'out'
+ ? $m->pretty_recipient
+ : $m->pretty_sender));
+ }
+
+ my $body = $m->{body};
+ $body =~ tr/\n/ /;
+ $line .= $body;
+ $line = BarnOwl::Style::boldify($line) if ($m->is_personal && lc($m->direction) eq 'in');
+ return $line;
+}
+
+# Format locally generated messages
+sub format_local($)
+{
+ my $m = shift;
+ my $type = uc($m->{type});
+ my $line = sprintf(BASE_FORMAT, '<', $type, '', '');
+ my $body = $m->{body};
+ $body =~ tr/\n/ /;
+ return $line.$body;
+}
+
package BarnOwl::Style;
# This takes a zephyr to be displayed and modifies it to be displayed
Modified: branches/barnowl_unicode/owl/stylefunc.c
===================================================================
--- branches/barnowl_unicode/owl/stylefunc.c 2008-01-16 07:59:06 UTC (rev 881)
+++ branches/barnowl_unicode/owl/stylefunc.c 2008-01-16 18:46:37 UTC (rev 882)
@@ -219,133 +219,3 @@
owl_free(header);
}
}
-
-void owl_stylefunc_oneline(owl_fmtext *fm, owl_message *m)
-{
- char *tmp;
- char *baseformat="%s %-13.13s %-11.11s %-12.12s ";
- char *sender, *recip;
-#ifdef HAVE_LIBZEPHYR
- ZNotice_t *n;
-#endif
-
- sender=short_zuser(owl_message_get_sender(m));
- recip=short_zuser(owl_message_get_recipient(m));
-
- if (owl_message_is_type_zephyr(m)) {
-#ifdef HAVE_LIBZEPHYR
- n=owl_message_get_notice(m);
-
- owl_fmtext_append_spaces(fm, OWL_TAB);
-
- if (owl_message_is_loginout(m)) {
- char *host, *tty;
-
- host=owl_message_get_attribute_value(m, "loginhost");
- tty=owl_message_get_attribute_value(m, "logintty");
-
- if (owl_message_is_login(m)) {
- tmp=owl_sprintf(baseformat, "<", owl_message_is_pseudo(m)?"LOGIN-P":"LOGIN", "", sender);
- owl_fmtext_append_normal(fm, tmp);
- owl_free(tmp);
- } else if (owl_message_is_logout(m)) {
- tmp=owl_sprintf(baseformat, "<", owl_message_is_pseudo(m)?"LOGOUT-P":"LOGOUT", "", sender);
- owl_fmtext_append_normal(fm, tmp);
- owl_free(tmp);
- }
-
- owl_fmtext_append_normal(fm, "at ");
- owl_fmtext_append_normal(fm, host ? host : "");
- owl_fmtext_append_normal(fm, " ");
- owl_fmtext_append_normal(fm, tty ? tty : "");
- owl_fmtext_append_normal(fm, "\n");
-
- } else if (owl_message_is_ping(m)) {
- tmp=owl_sprintf(baseformat, "<", "PING", "", sender);
- owl_fmtext_append_normal(fm, tmp);
- owl_fmtext_append_normal(fm, "\n");
- owl_free(tmp);
-
- } else {
- if (owl_message_is_direction_in(m)) {
- tmp=owl_sprintf(baseformat, "<", owl_message_get_class(m), owl_message_get_instance(m), sender);
- } else if (owl_message_is_direction_out(m)) {
- tmp=owl_sprintf(baseformat, ">", owl_message_get_class(m), owl_message_get_instance(m), recip);
- } else {
- tmp=owl_sprintf(baseformat, "-", owl_message_get_class(m), owl_message_get_instance(m), sender);
- }
- owl_fmtext_append_normal(fm, tmp);
- if (tmp) owl_free(tmp);
-
- tmp=owl_strdup(owl_message_get_body(m));
- owl_text_tr(tmp, '\n', ' ');
- owl_fmtext_append_ztext(fm, tmp);
- owl_fmtext_append_normal(fm, "\n");
- if (tmp) owl_free(tmp);
- }
-
- /* make personal messages bold for smaat users */
- if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES) &&
- owl_message_is_personal(m) &&
- owl_message_is_direction_in(m)) {
- owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD);
- }
-
- owl_free(sender);
- owl_free(recip);
-#endif
- } else if (owl_message_is_type_aim(m)) {
- owl_fmtext_append_spaces(fm, OWL_TAB);
- if (owl_message_is_login(m)) {
- tmp=owl_sprintf(baseformat, "<", "AIM LOGIN", "", owl_message_get_sender(m));
- owl_fmtext_append_normal(fm, tmp);
- owl_fmtext_append_normal(fm, "\n");
- if (tmp) owl_free(tmp);
- } else if (owl_message_is_logout(m)) {
- tmp=owl_sprintf(baseformat, "<", "AIM LOGOUT", "", owl_message_get_sender(m));
- owl_fmtext_append_normal(fm, tmp);
- owl_fmtext_append_normal(fm, "\n");
- if (tmp) owl_free(tmp);
- } else {
- if (owl_message_is_direction_in(m)) {
- tmp=owl_sprintf(baseformat, "<", "AIM", "", owl_message_get_sender(m));
- owl_fmtext_append_normal(fm, tmp);
- if (tmp) owl_free(tmp);
- } else if (owl_message_is_direction_out(m)) {
- tmp=owl_sprintf(baseformat, ">", "AIM", "", owl_message_get_recipient(m));
- owl_fmtext_append_normal(fm, tmp);
- if (tmp) owl_free(tmp);
- }
-
- tmp=owl_strdup(owl_message_get_body(m));
- owl_text_tr(tmp, '\n', ' ');
- owl_fmtext_append_normal(fm, tmp);
- owl_fmtext_append_normal(fm, "\n");
- if (tmp) owl_free(tmp);
-
- /* make personal messages bold for smaat users */
- if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES) && owl_message_is_direction_in(m)) {
- owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD);
- }
- }
- } else if (owl_message_is_type_admin(m)) {
- owl_fmtext_append_spaces(fm, OWL_TAB);
- owl_fmtext_append_normal(fm, "< ADMIN ");
-
- tmp=owl_strdup(owl_message_get_body(m));
- owl_text_tr(tmp, '\n', ' ');
- owl_fmtext_append_normal(fm, tmp);
- owl_fmtext_append_normal(fm, "\n");
- if (tmp) owl_free(tmp);
- } else {
- owl_fmtext_append_spaces(fm, OWL_TAB);
- owl_fmtext_append_normal(fm, "< LOOPBACK ");
-
- tmp=owl_strdup(owl_message_get_body(m));
- owl_text_tr(tmp, '\n', ' ');
- owl_fmtext_append_normal(fm, tmp);
- owl_fmtext_append_normal(fm, "\n");
- if (tmp) owl_free(tmp);
- }
-
-}