|
unit main;
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
interface
|
|
|
|
uses
|
|
IniFiles,Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs;
|
|
|
|
type
|
|
|
|
{ TfrmMain }
|
|
|
|
TfrmMain = class(TForm)
|
|
procedure FormCreate(Sender: TObject);
|
|
private
|
|
procedure Cargarpantalla();
|
|
function LeerIni(): boolean;
|
|
procedure LeerSetupIni(archivo: string);
|
|
|
|
{ private declarations }
|
|
public
|
|
{ public declarations }
|
|
end;
|
|
|
|
var
|
|
frmMain: TfrmMain;
|
|
|
|
implementation
|
|
uses global, mensaje,icono;
|
|
{ TfrmMain }
|
|
Function Tfrmmain.LeerIni():boolean;
|
|
var
|
|
Mifichero:TMemIniFile;
|
|
stipo:string;
|
|
stiempo:string;
|
|
sarchivo:string;
|
|
begin
|
|
result:=false;
|
|
if FileExists(g_dirmensaje) then
|
|
begin
|
|
Mifichero:= TMemIniFile.create(g_dirmensaje);
|
|
with MiFichero do
|
|
begin
|
|
stipo:=ReadString('MENSAJE','tipo','');
|
|
if trim(stipo)='' then stipo:='0';
|
|
g_tipo:=strtoint(stipo);
|
|
g_mensaje:=ReadString('MENSAJE','mensaje','');
|
|
g_mensaje:=g_mensaje;
|
|
g_titulo:=ReadString('MENSAJE','titulo','');
|
|
g_titulo:=g_titulo;
|
|
g_usuario:=ReadString('MENSAJE','usuario','');
|
|
stiempo:=ReadString('MENSAJE','tiempo','');
|
|
if trim(stiempo)='' then stiempo:='9000';
|
|
g_tiempo:=strtoint(stiempo);
|
|
sarchivo:=ReadString('MENSAJE','archivo','');
|
|
if trim(sarchivo)='' then sarchivo:='0';
|
|
g_archivo:=strtoint(sarchivo);
|
|
Free;
|
|
result:=true;
|
|
end;
|
|
end
|
|
end;
|
|
procedure Tfrmmain.LeerSetupIni(archivo:string);
|
|
var
|
|
FicheroIni:TMemIniFile;
|
|
begin
|
|
try
|
|
FicheroIni:=TMemIniFile.create(archivo);
|
|
try
|
|
with FicheroIni do
|
|
begin
|
|
g_ExploradorArchivos:=ReadString('Entorno','Explorador archivos','nautilus');
|
|
if not FileExists('/usr/bin/'+g_ExploradorArchivos) then
|
|
begin
|
|
if FileExists('/usr/bin/nautilus') then
|
|
g_ExploradorArchivos:='nautilus'
|
|
else if FileExists('/usr/bin/thunar') then
|
|
g_ExploradorArchivos:='thunar';
|
|
end;
|
|
|
|
|
|
end;
|
|
finally
|
|
FicheroIni.free;
|
|
end;
|
|
except
|
|
writeLn('Error al cargar datos');
|
|
end;
|
|
end;
|
|
procedure Tfrmmain.Cargarpantalla();
|
|
begin
|
|
case g_tipo of
|
|
0:
|
|
begin
|
|
application.CreateForm(Tfrmicono,frmicono);
|
|
frmicono.ShowModal;
|
|
end;
|
|
else
|
|
begin
|
|
application.CreateForm(TfrmMensajes,frmmensajes);
|
|
frmMensajes.ShowModal;
|
|
end;
|
|
end;
|
|
application.Terminate;
|
|
end;
|
|
procedure TfrmMain.FormCreate(Sender: TObject);
|
|
begin
|
|
g_usuario:=GetEnvironmentVariable('HOME');
|
|
g_carpeta:=g_usuario+'/recibidos_profesor/';
|
|
//g_carpeta:='/tmp/aulalinex/recibidos_profesor/';
|
|
g_dirmensaje:= g_carpeta+'.mensaje.ini';
|
|
if FileExists(g_fichero_conf) then
|
|
LeerSetupIni(g_fichero_conf);
|
|
if LeerIni() then
|
|
CargarPantalla()
|
|
else
|
|
application.Terminate;
|
|
end;
|
|
|
|
initialization
|
|
{$I main.lrs}
|
|
|
|
end.
|
|
|