desarrollosconsejeria/adtos-aula/1.7-0/serveradtosaula/serveradtosaula.lpr @ 23a384b9
23a384b9 | Elisa | {
|
|
Adtos 1.6 Software de gestión de Aulas Tecnológicas
|
|||
Copyright (C) 2008-20012, Manuel Narváez Martínez
|
|||
Programación: Manuel Narváez Martínez <mnarvaez007@gmail.com>
|
|||
Diseño gráfico: Ana María Zamora Moreno
|
|||
Desarrollado con Lazarus 0.9.26
|
|||
This program is free software; you can redistribute it and/or modify
|
|||
it under the terms of the GNU General Public License as published by
|
|||
the Free Software Foundation; either version 2 of the License, or
|
|||
(at your option) any later version.
|
|||
This program is distributed in the hope that it will be useful,
|
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|||
GNU General Public License for more details.
|
|||
You should have received a copy of the GNU General Public License
|
|||
along with this program; if not, write to the Free Software
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||
}
|
|||
program serveradtosaula;
|
|||
{$mode objfpc}{$H+}
|
|||
uses
|
|||
cthreads,
|
|||
Classes, SysUtils, CustApp
|
|||
{ you can add units after this }, globales, demonio, clservidor,
|
|||
clejucutaasi, clcomandosroot,clpingCliente, clpingPortatil;
|
|||
type
|
|||
{ TMyApplication }
|
|||
TMyApplication = class(TCustomApplication)
|
|||
private
|
|||
procedure hallaUsuarioActivo();
|
|||
protected
|
|||
procedure DoRun; override;
|
|||
public
|
|||
constructor Create(TheOwner: TComponent); override;
|
|||
destructor Destroy; override;
|
|||
end;
|
|||
{ TMyApplication }
|
|||
procedure TMyApplication.DoRun;
|
|||
var
|
|||
mis_datos: String;
|
|||
begin
|
|||
if (g_IpEsteEquipo='') then
|
|||
begin
|
|||
if g_contador_enviar_datos>TIEMPO_HALLAIP_ENVIADATOS then
|
|||
begin
|
|||
g_IpEsteEquipo:=miservidor.ObtenerMiIp();
|
|||
if (g_IpEsteEquipo<>'') then
|
|||
begin
|
|||
miservidor.ip:=g_IpEsteEquipo;
|
|||
miservidor.MAC:=miservidor.ObtenerMiMAC();
|
|||
miservidor.Host:=miservidor.ObtenerHost();
|
|||
g_datos_equipo_profesor:=miservidor.Host+'&'+miservidor.ip+'&'+miservidor.MAC+'&'+g_usuario+'&1';
|
|||
g_tsEquiposAlumnos.text:=g_datos_equipo_profesor;
|
|||
mis_datos:=miservidor.Host+'&'+miservidor.ip+'&'+miservidor.MAC+'&'+g_Dominio;
|
|||
miservidor.EnviarDatosEquipo(mis_datos);
|
|||
g_contador_revision_equipos:=1200;
|
|||
DataModule1.IniciaRevisionAula();
|
|||
end;
|
|||
g_contador_enviar_datos:=0;
|
|||
end;
|
|||
inc(g_contador_enviar_datos);
|
|||
end;
|
|||
if (g_contador_usuario>TIEMPO_REFRESCO_USUARIO) then
|
|||
begin
|
|||
g_contador_usuario:=0;
|
|||
try
|
|||
hallaUsuarioActivo();
|
|||
except
|
|||
//writeln('Error al hallar usuario');
|
|||
end;
|
|||
end;
|
|||
inc(g_contador_usuario);
|
|||
if (g_contador_revision_equipos>TIEMPO_REFRESCO_ESTADO_AULA) and (g_IpEsteEquipo<>'') then
|
|||
begin
|
|||
g_contador_revision_equipos:=0;
|
|||
DataModule1.IniciaRevisionAula();
|
|||
end;
|
|||
inc(g_contador_revision_equipos);
|
|||
sleep(50);
|
|||
end;
|
|||
procedure TMyApplication.hallaUsuarioActivo();
|
|||
var
|
|||
comando_usuario,nombreusu:string;
|
|||
begin
|
|||
try
|
|||
comando_usuario:='who| grep -v "unknown" | grep -v "pts"| grep ' +QuotedStr('\(:0\)')+' | head -n 1| cut -f1 -d" "';
|
|||
nombreusu:=HallarDato(comando_usuario);
|
|||
if trim(nombreusu)='' then nombreusu:=' ';
|
|||
g_usuario:=nombreusu;
|
|||
//writeln('usuario ' +g_usuario);
|
|||
except
|
|||
g_usuario:='';
|
|||
end;
|
|||
end;
|
|||
constructor TMyApplication.Create(TheOwner: TComponent);
|
|||
const
|
|||
ORD_HOST:string='hostname | cut -f1 -d"."';
|
|||
ORD_DOMINIO:string='hostname | cut -f2 -d"."';
|
|||
begin
|
|||
inherited Create(TheOwner);
|
|||
g_datos_equipo_profesor:='';
|
|||
g_host:=Trim(HallarDato(ORD_HOST));
|
|||
g_Dominio:=HallarDato(ORD_DOMINIO);
|
|||
if g_Dominio='' then g_Dominio:='general';
|
|||
if g_host = g_Dominio then g_Dominio:='general';
|
|||
StopOnException:=True;
|
|||
hallaUsuarioActivo();
|
|||
end;
|
|||
destructor TMyApplication.Destroy;
|
|||
begin
|
|||
inherited Destroy;
|
|||
end;
|
|||
var
|
|||
Application: TMyApplication;
|
|||
{$IFDEF WINDOWS}{$R serveradtosaula.rc}{$ENDIF}
|
|||
begin
|
|||
Application:=TMyApplication.Create(nil);
|
|||
Application.Title:='ServerAdtosAula';
|
|||
Application.Run;
|
|||
Application.Free;
|
|||
end.
|