Commit c9d7c2eb authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(send_async_new_presentation): New function.

(do_set_presentation): Call it.  Clean up variable names, and
	remember the text statuses of the old and new presentation so
	they can be passed to send_async_new_presentation().  Include
	the text number of the old presentation in the error message
	that is printed if the old presentation lacks a mark.
parent f3360e6c
/*
* $Id: conference.c,v 0.79 2003/07/12 22:26:32 ceder Exp $
* $Id: conference.c,v 0.80 2003/08/08 20:57:41 ceder Exp $
* Copyright (C) 1991-2002 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -1231,6 +1231,44 @@ set_keep_commented(Conf_no conf_no,
return OK;
}
static void
send_async_new_presentation(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_presentation] == 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_presentation(cptr, conf_no, used_old, used_new);
}
}
/*
* Change presentation of a conference. If text_no is 0, there will be
* no presentation.
......@@ -1239,25 +1277,24 @@ set_keep_commented(Conf_no conf_no,
Success
do_set_presentation(Conf_no conf_no,
Conference * conf_c,
Text_no text_no)
Text_no new_text_no)
{
Text_stat * old_pres;
Text_stat * new_pres = NULL; /* Initialized to stop gcc complaining
* about this being used uninitialized.
* This initialization is in fact not needed
* since it would not be used uninitialized.*/
Text_stat * old_stat = NULL;
Text_stat * new_stat = NULL;
Text_no old_text_no = 0;
/* Check that the new presentation exists before deleting the old*/
if ( text_no != 0 )
if ( new_text_no != 0 )
{
GET_T_STAT(new_pres, text_no, FAILURE);
if ( new_pres->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("%s(%d, ptr, %lu): New presentation has %d marks.\n",
"LIMIT: do_set_presentation",
conf_no, (unsigned long)text_no, new_pres->no_of_marks);
err_stat = text_no;
"LIMIT: do_set_presentation",
conf_no,
(unsigned long)new_text_no, new_stat->no_of_marks);
err_stat = new_text_no;
kom_errno = KOM_MARK_LIMIT;
return FAILURE;
}
......@@ -1265,33 +1302,47 @@ do_set_presentation(Conf_no conf_no,
/* Unmark the previous presentation if it exists. */
if ( conf_c->presentation != 0
&& (old_pres = cached_get_text_stat(conf_c->presentation)) != NULL)
old_text_no = conf_c->presentation;
if (old_text_no != 0)
{
if ( old_pres->no_of_marks > 0 )
if ((old_stat = cached_get_text_stat(old_text_no)) == NULL)
{
/* FIXME (bug 85): This is not currently an error, but it
will be once bug 85 is fixed. */
kom_log("do_set_presentation(): Old presentation %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_pres->no_of_marks;
mark_text_as_changed( conf_c->presentation );
--old_stat->no_of_marks;
mark_text_as_changed(conf_c->presentation);
}
else
{
kom_log("ERROR: do_set_presentation(%d, ptr, %lu): "
"Old presentation not marked.\n",
conf_no, (unsigned long)text_no);
"Old presentation %lu not marked.\n",
conf_no,
(unsigned long)new_text_no,
(unsigned long)old_text_no);
}
}
/* Mark the new presentation */
if ( text_no != 0 )
if (new_text_no != 0)
{
++new_pres->no_of_marks;
mark_text_as_changed( text_no );
++new_stat->no_of_marks;
mark_text_as_changed(new_text_no);
}
conf_c->presentation = text_no;
mark_conference_as_changed( conf_no );
conf_c->presentation = new_text_no;
mark_conference_as_changed(conf_no);
send_async_new_presentation(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