Commit 3cfb93d3 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(who_is_on_dynamic): New function.

(get_static_session_info): New function.
(user_active): New function.
(get_session_info): The idle-time is calculated using active_time
	instead of last_request.
(get_session_info_ident): Likewise.
parent e30d6109
/*
* $Id: session.c,v 0.32 1996/07/28 12:48:32 ceder Exp $
* $Id: session.c,v 0.33 1996/08/01 23:56:17 ceder Exp $
* Copyright (C) 1991, 1992, 1993, 1994 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -28,7 +28,7 @@
* Session control and miscellaneous.
*/
static char *rcsid = "$Id: session.c,v 0.32 1996/07/28 12:48:32 ceder Exp $";
static char *rcsid = "$Id: session.c,v 0.33 1996/08/01 23:56:17 ceder Exp $";
#include "rcs.h"
USE(rcsid);
......@@ -523,6 +523,76 @@ who_is_on_ident( Who_info_ident_list *result )
}
/*
* Get info about what all the currently logged in persons are doing.
*/
extern Success
who_is_on_dynamic(int want_visible,
int want_invisible,
Dynamic_session_info_list *result)
{
Connection *cptr;
long no_of_clients = 0;
long i;
Session_no session;
int include_it = 0;
time_t tn;
tn = time(NULL);
cptr = active_connection;
for ( session = 0; (session = traverse_connections(session)) != 0; )
{
cptr = get_conn_by_number(session);
if (cptr->person == NULL || cptr->invisible == TRUE)
include_it = want_invisible;
else
include_it = want_visible;
if (include_it != 0)
++no_of_clients;
}
result->no_of_sessions = no_of_clients;
result->sessions = tmp_alloc(no_of_clients * sizeof(Dynamic_session_info));
for ( session = 0, i = 0;
i < no_of_clients && (session = traverse_connections(session)) != 0; )
{
cptr = get_conn_by_number(session);
if (cptr->person == NULL || cptr->invisible == TRUE)
include_it = want_invisible;
else
include_it = want_visible;
if (include_it != 0)
{
init_dynamic_session_info(&result->sessions[i]);
result->sessions[i].session = cptr->session_no;
result->sessions[i].person = cptr->pers_no;
result->sessions[i].working_conference = cptr->cwc;
result->sessions[i].idle_time = ldifftime(tn, cptr->active_time);
if (cptr->person == NULL || cptr->invisible == TRUE)
result->sessions[i].invisible = TRUE;
else
result->sessions[i].invisible = FALSE;
result->sessions[i].what_am_i_doing = cptr->what_am_i_doing;
++i;
}
}
if ( i != no_of_clients )
log("who_is_on_dynamic: i == %ld, no_of_clients == %ld\n",
i, no_of_clients);
return OK;
}
extern Success
get_session_info (Session_no session_no,
Session_info *result)
......@@ -541,7 +611,7 @@ get_session_info (Session_no session_no,
result->working_conference = cptr->cwc;
result->session = cptr->session_no;
result->connection_time = cptr->session_start;
result->idle_time = ldifftime(time(NULL), cptr->last_request);
result->idle_time = ldifftime(time(NULL), cptr->active_time);
/* Backward compatibility. result->username is free()d in
prot_a_reply() prot-a.c. */
......@@ -556,6 +626,34 @@ get_session_info (Session_no session_no,
}
}
extern Success
get_static_session_info (Session_no session_no,
Static_session_info *result)
{
Connection *cptr;
CHK_LOGIN(FAILURE);
cptr = get_conn_by_number(session_no);
if ( cptr != NULL )
{
init_static_session_info(result);
result->username = cptr->username;
result->hostname = cptr->hostname;
result->ident_user = cptr->ident_user;
result->connection_time = cptr->session_start;
return OK;
}
else
{
kom_errno = KOM_UNDEF_SESSION;
return FAILURE;
}
}
extern Success
get_session_info_ident (Session_no session_no,
Session_info_ident *result)
......@@ -574,7 +672,7 @@ get_session_info_ident (Session_no session_no,
result->working_conference = cptr->cwc;
result->session = cptr->session_no;
result->connection_time = cptr->session_start;
result->idle_time = ldifftime(time(NULL), cptr->last_request);
result->idle_time = ldifftime(time(NULL), cptr->active_time);
result->username = cptr->username;
result->hostname = cptr->hostname;
result->ident_user = cptr->ident_user;
......@@ -819,3 +917,10 @@ query_async(Number_list *result)
return OK;
}
extern Success
user_active(void)
{
time(&active_connection->active_time);
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