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

(perform_subtraction): New static function, extracted from

	do_sub_recpt.  Only send async-sub-recipient if the new
	argument want_async is true.
(do_sub_recpt): Code simplified by creation of perform_subtraction().
	New argument: want_async (see above).
(do_delete_text): Tell do_sub_recpt that we don't want any
	async-sub-recipient messages.
(sub_recipient): Tell do_sub_recpt to send async-sub-recipient messages.
parent 621fec31
/*
* $Id: text.c,v 0.68 1999/05/30 09:05:40 ceder Exp $
* $Id: text.c,v 0.69 1999/05/30 14:11:25 ceder Exp $
* Copyright (C) 1991-1999 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -34,7 +34,7 @@
#endif
static const char *
rcsid = "$Id: text.c,v 0.68 1999/05/30 09:05:40 ceder Exp $";
rcsid = "$Id: text.c,v 0.69 1999/05/30 14:11:25 ceder Exp $";
#include "rcs.h"
USE(rcsid);
......@@ -634,90 +634,88 @@ send_async_sub_recipient (Text_no text_no, Text_stat *text_s,
}
}
/*
* Delete the recipient ``conf_no'' from text ``text_no''.
* The misc-item is locate at position ``loc'' in the miscinfolist.
* ``text_s'' and ``conf_s'' must be supplied. An async-sub-recipient
* message will be sent if ``want_async'' is true.
*/
static Success
perform_subtraction(Text_no text_no,
Text_stat *text_s,
Conf_no conf_no,
Conference *conf_s, /* NULL if the conf_no doesn't exist */
int loc,
Bool want_async)
{
if (conf_s != NULL)
{
/* Only if the conference exists: */
if (text_s->misc_items[loc+1].type == loc_no)
{
l2g_delete(&conf_s->texts,
text_s->misc_items[loc+1].datum.local_no);
mark_conference_as_changed (conf_no);
}
else
{
kom_log("Bad misc-info-list detected in perform_subtraction()"
" for text number %lu.\n", (unsigned long)text_no);
}
}
if (want_async)
send_async_sub_recipient(text_no, text_s, conf_no,
text_s->misc_items[loc].type);
do_delete_misc(&text_s->no_of_misc, text_s->misc_items, loc);
mark_text_as_changed (text_no);
return OK;
}
/*
* Delete a recipient from a text. Does not fail if the recipient doesn't
* exist - that is not an error.
*
* FIXME: 1999-05-30: is it really possible for the recipient to be
* nonexisting? When?
*/
static Success
do_sub_recpt (Text_no text_no,
Text_stat * text_s, /* May be NULL */
Conf_no conf_no,
Conference * conf_s ) /* May be NULL */
Conference * conf_s, /* May be NULL */
Bool want_async)
{
int i;
Info_type removed;
if ( text_s == NULL )
if (text_s == NULL)
GET_T_STAT(text_s, text_no, FAILURE);
if ( conf_s == NULL )
{
if (conf_s == NULL)
conf_s = cached_get_conf_stat( conf_no ); /* Might still be NULL. */
}
for ( i = 0; i < text_s->no_of_misc; i++ )
for (i = 0; i < text_s->no_of_misc; i++)
{
switch ( text_s->misc_items[ i ].type)
switch (text_s->misc_items[i].type)
{
case recpt:
if ( text_s->misc_items[ i ].datum.recipient == conf_no )
{
if ( conf_s != NULL )
{
/* Only if the conference exists: */
l2g_delete(&conf_s->texts,
text_s->misc_items[ i+1 ].datum.local_no);
mark_conference_as_changed (conf_no);
}
removed = text_s->misc_items[i].type;
send_async_sub_recipient(text_no, text_s, conf_no, removed);
do_delete_misc ( &text_s->no_of_misc, text_s->misc_items, i );
mark_text_as_changed (text_no);
return OK;
}
if (text_s->misc_items[i].datum.recipient == conf_no)
return perform_subtraction(text_no, text_s, conf_no, conf_s,
i, want_async);
break;
case cc_recpt:
if ( text_s->misc_items[ i ].datum.cc_recipient == conf_no )
{
if ( conf_s != NULL )
{
l2g_delete(&conf_s->texts,
text_s->misc_items[ i+1 ].datum.local_no);
mark_conference_as_changed( conf_no );
}
removed = text_s->misc_items[i].type;
send_async_sub_recipient(text_no, text_s, conf_no, removed);
do_delete_misc( &text_s->no_of_misc, text_s->misc_items, i );
mark_text_as_changed( text_no );
return OK;
}
if (text_s->misc_items[i].datum.cc_recipient == conf_no)
return perform_subtraction(text_no, text_s, conf_no, conf_s,
i, want_async);
break;
case bcc_recpt:
if ( text_s->misc_items[ i ].datum.bcc_recipient == conf_no )
{
if ( conf_s != NULL )
{
l2g_delete(&conf_s->texts,
text_s->misc_items[ i+1 ].datum.local_no);
mark_conference_as_changed( conf_no );
}
removed = text_s->misc_items[i].type;
send_async_sub_recipient(text_no, text_s, conf_no, removed);
do_delete_misc( &text_s->no_of_misc, text_s->misc_items, i );
mark_text_as_changed( text_no );
return OK;
}
if (text_s->misc_items[i].datum.bcc_recipient == conf_no)
return perform_subtraction(text_no, text_s, conf_no, conf_s,
i, want_async);
break;
case comm_to:
......@@ -1614,25 +1612,27 @@ do_delete_text(Text_no text_no,
switch ( text_s->misc_items[ 0 ].type )
{
case recpt:
if ( do_sub_recpt(text_no, text_s,
text_s->misc_items[ 0 ].datum.recipient, NULL)
!= OK )
if (do_sub_recpt(text_no, text_s,
text_s->misc_items[0].datum.recipient,
NULL, FALSE)
!= OK)
restart_kom("do_delete_text(): error pos 1.\n");
break;
case cc_recpt:
if ( do_sub_recpt(text_no, text_s,
text_s->misc_items[ 0 ].datum.cc_recipient, NULL)
!= OK )
if (do_sub_recpt(text_no, text_s,
text_s->misc_items[0].datum.cc_recipient,
NULL, FALSE)
!= OK)
restart_kom("do_delete_text(): error pos 2.\n");
break;
case bcc_recpt:
if ( do_sub_recpt(text_no, text_s,
text_s->misc_items[ 0 ].datum.bcc_recipient,
NULL)
!= OK )
restart_kom("do_delete_text(): error pos 2.\n");
if (do_sub_recpt(text_no, text_s,
text_s->misc_items[0].datum.bcc_recipient,
NULL, FALSE)
!= OK)
restart_kom("do_delete_text(): error pos 3.\n");
break;
......@@ -3029,7 +3029,7 @@ sub_recipient( Text_no text_no,
return FAILURE;
}
return do_sub_recpt( text_no, text_s, conf_no, conf_c );
return do_sub_recpt(text_no, text_s, conf_no, conf_c, TRUE);
}
/*
......
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