desarrollosconsejeria/adtos-aula/1.7-0/adtosmensajes/main.pas @ 23a384b9
a2ba555f | Elisa | unit main;
|
|
{$mode objfpc}{$H+}
|
|||
interface
|
|||
uses
|
|||
23a384b9 | Elisa | HTTPDefs, IniFiles,Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs;
|
|
a2ba555f | Elisa | ||
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','');
|
|||
23a384b9 | Elisa | g_mensaje:=HTTPDecode(g_mensaje);
|
|
a2ba555f | Elisa | g_titulo:=ReadString('MENSAJE','titulo','');
|
|
23a384b9 | Elisa | g_titulo:=HTTPDecode(g_titulo);
|
|
a2ba555f | Elisa | 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');
|
|||
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');
|
|||
23a384b9 | Elisa | g_carpeta:=g_usuario+'/recibidos_administrador/';
|
|
a2ba555f | Elisa | 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.
|