Commit 086fc6b7 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(send_async_new_motd): New function.

(do_set_etc_motd): Call it.  Clean up variable names.
parent ec06bb01
/*
* $Id: conference.c,v 0.80 2003/08/08 20:57:41 ceder Exp $
* $Id: conference.c,v 0.81 2003/08/08 21:45:14 ceder Exp $
* Copyright (C) 1991-2002 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -1285,13 +1285,13 @@ do_set_presentation(Conf_no conf_no,
/* Check that the new presentation exists before deleting the old*/
if ( new_text_no != 0 )
if (new_text_no != 0)
{
GET_T_STAT(new_stat, new_text_no, FAILURE);
if ( new_stat->no_of_marks >= param.max_marks_text )
if (new_stat->no_of_marks >= param.max_marks_text)
{
kom_log("%s(%d, ptr, %lu): New presentation has %d marks.\n",
"LIMIT: do_set_presentation",
kom_log("LIMIT: do_set_presentation(%d, ptr, %lu): "
"New presentation has %d marks.\n",
conf_no,
(unsigned long)new_text_no, new_stat->no_of_marks);
err_stat = new_text_no;
......@@ -1317,7 +1317,7 @@ do_set_presentation(Conf_no conf_no,
else if (old_stat->no_of_marks > 0)
{
--old_stat->no_of_marks;
mark_text_as_changed(conf_c->presentation);
mark_text_as_changed(old_text_no);
}
else
{
......@@ -1346,6 +1346,44 @@ do_set_presentation(Conf_no conf_no,
return OK;
}
static void
send_async_new_motd(Conf_no conf_no,
Text_no old_tno,
Text_stat *old_stat,
Text_no new_tno,
Text_stat *new_stat)
{
Session_no i = 0;
Connection *cptr;
Text_no used_old;
Text_no used_new;
if (!param.send_async_messages)
return;
while ((i = traverse_connections(i)) != 0)
{
cptr = get_conn_by_number(i);
/* Check the want_async here to avoid the potentially
expensive calls to access_perm. */
if (cptr->want_async[ay_new_motd] == FALSE)
continue;
if (access_perm(conf_no, cptr, read_protected) < read_protected)
continue;
used_old = text_read_access(cptr, old_tno, old_stat) ? old_tno : 0;
used_new = text_read_access(cptr, new_tno, new_stat) ? new_tno : 0;
if (used_old == used_new)
continue;
async_new_motd(cptr, conf_no, used_old, used_new);
}
}
/*
* Change motd of a conference. If text_no is 0, there will be
* no motd.
......@@ -1354,22 +1392,24 @@ do_set_presentation(Conf_no conf_no,
Success
do_set_etc_motd(Conf_no conf_no,
Conference * conf_c,
Text_no text_no)
Text_no new_text_no)
{
Text_stat * old_motd;
Text_stat * new_motd = NULL; /* To stop gcc complaining. */
Text_stat * old_stat = NULL;
Text_stat * new_stat = NULL;
Text_no old_text_no = 0;
/* Check that the new motd exists before deleting the old*/
if ( text_no != 0 )
if (new_text_no != 0)
{
GET_T_STAT(new_motd, text_no, FAILURE);
if ( new_motd->no_of_marks >= param.max_marks_text )
GET_T_STAT(new_stat, new_text_no, FAILURE);
if (new_stat->no_of_marks >= param.max_marks_text)
{
kom_log("LIMIT: do_set_etc_motd(%d, ptr, %lu): "
"New motd has %d marks.\n",
conf_no, (unsigned long)text_no, new_motd->no_of_marks);
err_stat = text_no;
conf_no,
(unsigned long)new_text_no, new_stat->no_of_marks);
err_stat = new_text_no;
kom_errno = KOM_MARK_LIMIT;
return FAILURE;
}
......@@ -1377,31 +1417,47 @@ do_set_etc_motd(Conf_no conf_no,
/* Unmark the previous motd if it exists. */
if ( conf_c->msg_of_day != 0
&& (old_motd = cached_get_text_stat(conf_c->msg_of_day)) != NULL)
old_text_no = conf_c->msg_of_day;
if (old_text_no != 0)
{
if ( old_motd->no_of_marks > 0 )
if ((old_stat = cached_get_text_stat(old_text_no)) == NULL)
{
/* FIXME (bug 86): This is not currently an error, but it
will be once bug 86 is fixed. */
kom_log("do_set_etc_motd(): Old motd %lu of conf %lu"
" does not exist.\n",
(unsigned long)old_text_no, (unsigned long)conf_no);
old_text_no = 0;
}
else if (old_stat->no_of_marks > 0)
{
--old_motd->no_of_marks;
mark_text_as_changed( conf_c->msg_of_day );
--old_stat->no_of_marks;
mark_text_as_changed(old_text_no);
}
else
{
kom_log("ERROR: do_set_etc_motd(): Old motd not marked.\n");
kom_log("ERROR: do_set_etc_motd(%d, ptr, %lu): "
"Old motd %lu not marked.\n",
conf_no,
(unsigned long)new_text_no,
(unsigned long)old_text_no);
}
}
/* Mark the new motd */
if ( text_no != 0 )
if (new_text_no != 0)
{
++new_motd->no_of_marks;
mark_text_as_changed( text_no );
++new_stat->no_of_marks;
mark_text_as_changed(new_text_no);
}
conf_c->msg_of_day = text_no;
mark_conference_as_changed( conf_no );
conf_c->msg_of_day = new_text_no;
mark_conference_as_changed(conf_no);
send_async_new_motd(conf_no,
old_text_no, old_stat,
new_text_no, new_stat);
return OK;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment