# -*-perl-*-
# keitairc/lib/plugins/00all
# `l̑SbZ[W{
# $Id: 00all,v 1.2 2008/01/13 15:31:09 morimoto Exp $
# $Source: /cvsroot/keitairc/lib/plugins/00all,v $

$plugin = {
	name => 'all',
	action_imprementation => sub {
		my ($request, $name, $session_id, $param_string) = @_;
		my $cid = $param_string;
		my $channel = $::ib->cid2name($cid);

		::send_message($request, $channel);

		my $buf;
		my $no_message_here_yet;
		if(defined($::ib->name($cid))){
			if(length($::ib->buffer($cid))){
				if($::cf->show_newmsgonly() && $::ib->message_added()){
					$buf = ::render_line($::ib->unread($cid), $session_id) ||
						'(ǔ͂܂)';
					$buf .= sprintf('<br /><a accesskey="5" href="../all/%s">[5] S</a>', $cid);
				}else{
					$buf = ::render_line($::ib->buffer($cid), $session_id);
				}
			}else{
				$no_message_here_yet = 1;
			}
		}else{
			$buf = 'wق݂͑܂';
		}

		$::ib->message_added(0); # clear check flags
		$::ib->clear_unread($cid);

		my $ci = new Keitairc::ClientInfo($request);
		my $view = new Keitairc::View($::cf, $ci);

		my $p;
		$p->{buf} = $buf;
		$p->{channel_compact} = $::ib->compact_channel_name($cid);
		$p->{cid} = $cid;
		$p->{no_message_here_yet} = $no_message_here_yet;
		return $view->render('all.html', $p);
	}
};

1;
