Commit f5a623d1 authored by Per Cederqvist's avatar Per Cederqvist

(create_text_check_misc): New argument: need_public_jubel.

(struct jubel): New field: public.
(register_jubel): New argument: public.
(ok_to_create_next_text): New result parameter: must_be_public.
(do_create_text): Check for jubels that must be public.
parent 5344e4f6
/*
* $Id: text.c,v 0.92 2001/12/28 20:00:02 ceder Exp $
* $Id: text.c,v 0.93 2002/02/15 03:51:49 ceder Exp $
* Copyright (C) 1991-2001 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -1662,7 +1662,8 @@ check_double_comm(const Misc_info *misc,
static Success
create_text_check_misc(u_short *no_of_misc,
Misc_info *misc,
Bool anonymous)
Bool anonymous,
Bool need_public_jubel)
{
int i;
Text_stat *parent;
......@@ -1738,7 +1739,17 @@ create_text_check_misc(u_short *no_of_misc,
kom_errno = KOM_ANON_REJECTED;
return FAILURE;
}
/* Check if this is a public conference. */
if (need_public_jubel)
{
Conf_type conf_type;
conf_type = cached_get_conf_type(addressee);
if (!conf_type.rd_prot)
need_public_jubel = FALSE;
}
break;
case loc_no: /* Ignore loc_no */
......@@ -1764,6 +1775,15 @@ create_text_check_misc(u_short *no_of_misc,
}
}
if (need_public_jubel)
{
/* We still have not found an open conference among the recipients. */
err_stat = 0;
kom_errno = KOM_TEMPFAIL;
kom_log("Jubel stopped because no public recipient was found.\n");
return FAILURE;
}
return OK;
}
......@@ -1954,6 +1974,7 @@ struct jubel {
Pers_no bad_guy;
Text_no divisor; /* 0 is used to represent infinity */
Text_no remainder;
Bool public; /* Text must be sent to a public conference */
};
static struct jubel *jubel_root = NULL;
......@@ -1969,13 +1990,15 @@ static struct jubel *jubel_root = NULL;
void
register_jubel(Pers_no pno,
Text_no divis, /* 0 if no division should be made. */
Text_no tno)
Text_no tno,
Bool public)
{
struct jubel *j = smalloc(sizeof(struct jubel));
j->next = jubel_root;
j->bad_guy = pno;
j->divisor = divis;
j->remainder = tno;
j->public = public;
jubel_root = j;
}
......@@ -1998,12 +2021,15 @@ free_all_jubel(void)
/* Check if it is ok for ACTPERS to create the next text. */
static Bool
ok_to_create_next_text(Connection *conn)
ok_to_create_next_text(const Connection *conn,
Bool *must_be_public) /* [out] */
{
struct jubel *j;
Text_no next_tno;
Bool is_jubel = FALSE;
*must_be_public = FALSE;
if (conn == NULL)
return FALSE;
......@@ -2016,17 +2042,26 @@ ok_to_create_next_text(Connection *conn)
if (conn->pers_no == j->bad_guy)
{
kom_log("Stopped person %d from creating jubel %lu.\n",
conn->pers_no, next_tno);
conn->pers_no, next_tno);
return FALSE;
}
else
is_jubel = TRUE;
if (j->public)
*must_be_public = TRUE;
}
}
if (is_jubel)
kom_log("Granted jubel %lu to person %d.\n",
next_tno, conn->pers_no);
{
if (*must_be_public)
kom_log("Granted jubel %lu to person %d, pending public check.\n",
next_tno, conn->pers_no);
else
kom_log("Granted jubel %lu to person %d.\n",
next_tno, conn->pers_no);
}
return TRUE;
}
......@@ -2150,6 +2185,7 @@ do_create_text(const String message,
{
Text_no text;
Text_stat *t_stat;
Bool need_public_jubel = FALSE;
CHK_CONNECTION(0);
CHK_LOGIN(0);
......@@ -2172,7 +2208,7 @@ do_create_text(const String message,
/* Check that the author is allowed to write this text number */
if (ok_to_create_next_text(active_connection) == FALSE)
if (ok_to_create_next_text(active_connection, &need_public_jubel) == FALSE)
{
err_stat = 0;
kom_errno = KOM_TEMPFAIL;
......@@ -2182,7 +2218,8 @@ do_create_text(const String message,
/* Check all misc-items and aux-items */
prepare_aux_item_list(aux, anonymous?0:ACTPERS);
if (create_text_check_misc(&no_of_misc, misc, anonymous) != OK
if (create_text_check_misc(&no_of_misc, misc, anonymous,
need_public_jubel) != OK
|| text_stat_check_add_aux_item_list(NULL, aux, ACTPERS, TRUE) != OK
|| (text = cached_create_text(message)) == 0)
{
......
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