-- Main is main file of main project written with Ada.
-- Main is Copyright (C) 2025 Manuel De Girardi ; 
--
--   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
--
-- Date := 2026-10-20 19:52:36 ; 
-- Version := 0.62.0a ; 
with M ; 
with M.Errors ; 
with M.Parameters ; 
with M.Options ; 
with M.Enums ; 
with M.Types ; 
with M.Interfaces ; 
with M.Logs;
use M.Logs;
with M.Account;
with M.Accounts_Manager;
use M.Account;
use M.Accounts_Manager;

with M.Projects_Manager;
use M.Projects_Manager;
with M.Project;
use M.Project;
with M.Classes;

with M.Ansi.Console ;
use M.Ansi.Console ;
with M.Ansi.Windows ;
with M.Windows ;
with M.Strings ;
with M.Main_Game;
use M.Main_Game;

with Gnat.Os_Lib;
use Gnat.Os_Lib;

with El.Lexics;
with El.Hander;
with El.Frames;
with El.Classe;

use El;
with M.Engineering;
with M.Engine;
with M.Servers ;
with Ada.Calendar;
use Ada.Calendar;
with Gnat.OS_Lib;
use Gnat;
with Gnat.Sha1;
use Gnat.Sha1;
with M.Attributes;
use M.Attributes;
with M.Results;
use M;
generic
   with package Ansi_Windows is new M.Ansi.Windows (<>);
   with package Windows is new M.Windows (<>) ;
   with package Hander is new El.Hander (<>) ;
   with package Words_Glossary is new El.Lexics.Glossary (<>);
   
package M.Agence is
   
   
         type Logon_Record is tagged
      record
	 Logname    : String_Access;
	 Password   : Sha1.Message_Digest;	 
      end record;      
   
   type Auth_Info is tagged
      record
	 Logname    : String_Access;
	 Password   : String_Access;
      end record;      

      
   type Identity_Record is new Logon_record with
      record
	 
	 Full_Name : access Wide_String;
	 Address   : access Wide_String;
	 City_Code : access Wide_String;
	 City_Name : access Wide_String;
	 Phone_Nb  : access Wide_String;
	 Email     : access Wide_String;
	 Web_Addr  : access Wide_String;
      end record;
   
   type Date_Record is tagged
      record
	 Year : Year_Range := Year_Range ' First;
	 Month : Month_Range := Month_Range ' First;
	 Day : Day_Range := Day_Range ' First;
	 Hours : Duration := Duration ' First;
      end record;
   
   Null_Date : constant Date_Record :=
     (Year_Range ' First, Month_Range ' First, Day_Range ' First, Duration ' First);

   
   type User_Record is new Auth_Info with
      record
	 Identity   : Identity_Record;
	 Home_Path  : access String;
	 Last_Visit : access Date_Record;
	 Alias_Set         : Attributs(2048);
	 Var_Set           : Attributs(2048);
      end record;
   
   
   type User_Access is access User_Record;
   type User_Array is array (Positive range <>) of User_Access;
   
   type User_Set(Max_Users : Positive) is tagged
      record
	 Set : User_Array(1..Max_Users);
	 User_Last : Natural := 0;
      end record;
        
   type Users_Ptr is access all User_Set;

   
   

   
   use Hander;
   use Words_Glossary;
   --use Hander.Words_Glossary;
   package Frames is new El.Frames (Windows);
   use Frames ;
   
   use M.Strings;
   package Classes is new M.Classes (Windows.Ansi_Windows);
   use Classes;
   package Engine is new M.Engine(Windows.Ansi_Windows);
   use Engine;
   package Engineering is new M.Engineering (Windows, Classes, Engine);
   use Engineering;
   --   use Engineer.Classes;
   
   procedure Save (Object : in Abstract_Access;
   		   Filename : in String);
   type Agence_Record;
   
   type Abstract_Mode is abstract tagged limited null record;
   
   type All_Mode(Name : Mode_Enum) is new Abstract_Mode with null record;
   
   type All_Access is access All_Mode'class;
   
   type Mode_Array is array (Natural range <>) of All_Access;
   
   type App_Access is access all Agence_Record;
   
   task type Console_Process(Agence : access Agence_Record) is
      entry Initialize;
      entry Receive(Wchar : in Wide_Character);
      entry Halt;
      entry Mode(Mode : out Mode_Enum);
      entry Reset;
      entry Switch (Mode : in Mode_Enum);
      entry Set_On_Esc(Is_Escape : in Boolean);      
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Begin_Of;
      entry End_Of;
      entry Del;
      entry Overwrite;  
      entry Full_Screen;
   end Console_Process;

   
   type Logs_Record(App : App_Access);
   task type Logs_Process (Mode : access Logs_Record; App : App_Access)  is
      --entry Initialize(App : in App_Access);
      entry Receive (Wchar : in Wide_Character);
      entry Wake_Up(Top : in Natural);
      entry Suspend;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Begin_Of;
      entry End_Of;
      entry Del;
      entry Overwrite;      
      entry Halt;
      entry Full_Screen;
   end Logs_Process;
   type Logs_Record(App : App_Access) is new All_Mode(Log) with
      record
	 Proc : Logs_Process(Logs_Record'Access, App);
      end record;
   
   
   type None_Record(App : App_Access);
   task type None_Process (Mode : access None_Record; App : App_Access) is
      --entry Initialize(App : in App_Access);
      entry Receive (Wchar : in Wide_Character);
      entry Halt;
      entry Suspend;
      entry Wake_Up(Top : in Natural);
      entry Refresh;
      entry Page_Up;
      entry Page_Down;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Full_Screen;

      entry Del;

      entry Begin_Of;

      entry End_Of;
      
      entry Overwrite;

      entry Screen_Print;
      
   end None_Process;
   type None_Record(App : App_Access) is new All_Mode(None) with
      record
	 Proc : None_Process(None_Record'Access, App);	    
      end record;
   
   
   subtype Cpu_String is String (1..6);
   
   Home_Dir : String := Getenv("HOME").all;
   
   task CPU_Process is
      entry Initialize;
      entry Cpu_Get(CPU_Usage : out CPU_String);
      
      entry Halt;
   end CPU_Process;
   
   
   
   -------------------------------------------------------------
   --                         Organizer                       --
   -------------------------------------------------------------
   --                                                         --
   --                                                         --
   --                                                         --   
   
   type Organizer_Record(App : App_Access);
   task type Organizer_Process (Mode : access Organizer_Record; App : App_Access)  is
      --entry Initialize(App : in App_Access);
      entry Receive (Wchar : in Wide_Character);
      entry Wake_Up(Top : in Natural);
      entry Suspend;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Begin_Of;
      entry End_Of;
      entry Del;
      entry Overwrite;      
      entry Halt;
      entry Full_Screen;
   end Organizer_Process;
   type Organizer_Record(App : App_Access) is new All_Mode(Organizer) with
      record
	 Proc : Organizer_Process(Organizer_Record'Access, App);
      end record;
   
      -------------------------------------------------------------
   --                         Kingdom                       --
   -------------------------------------------------------------
   --                                                         --
   --                                                         --
   --                                                         --   
   
   --  type Kingdom_Record(App : App_Access);
   --  task type Kingdom_Process (Mode : access Kingdom_Record; App : App_Access)  is
   --     --entry Initialize(App : in App_Access);
   --     entry Receive (Wchar : in Wide_Character);
   --     entry Wake_Up(Top : in Natural);
   --     entry Suspend;
   --     entry Page_Down;
   --     entry Page_Up;
   --     entry Up_Arrow;
   --     entry Down_Arrow;
   --     entry Left_Arrow;
   --     entry Right_Arrow;
   --     entry Begin_Of;
   --     entry End_Of;
   --     entry Del;
   --     entry Overwrite;      
   --     entry Halt;
   --     entry Full_Screen;
   --  end Kingdom_Process;
   --  type Kingdom_Record(App : App_Access) is new All_Mode(Kingdom) with
   --     record
   --  	 Proc : Kingdom_Process(Kingdom_Record'Access, App);
   --     end record;

   
   -------------------------------------------------------------
   --                      Virtual_Brain                      --
   -------------------------------------------------------------
   --                                                         --
   --                                                         --
   --                                                         --   
   
   type Vbrain_Record(App : App_Access);
   task type Vbrain_Process (Mode : access Vbrain_Record; App : App_Access)  is
      pragma Storage_Size (268435456);
      --entry Initialize(App : in App_Access);
      entry Receive (Wchar : in Wide_Character);
      entry Wake_Up(Top : in Natural);
      entry Suspend;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Begin_Of;
      entry End_Of;
      entry Del;
      entry Overwrite;      
      entry Halt;
      entry Dialog;
      entry Refresh;
      --entry Screen_Print;
      entry Full_Screen;
   end Vbrain_Process;
   type Vbrain_Record(App : App_Access) is new All_Mode(Dialog) with
      record
	 Proc : Vbrain_Process(Vbrain_Record'Access, App);
      end record;
   
   
   -------------------------------------------------------------
   --                      Workstation                        --
   -------------------------------------------------------------
   --                                                         --
   --                                                         --
   --                                                         --   
   
   type Workstation_Record(App : App_Access);
   task type Workstation_Process (Mode : access Workstation_Record; App : App_Access)  is
      pragma Storage_Size (268435456);
      --entry Initialize(App : in App_Access);
      entry Receive (Wchar : in Wide_Character);
      entry Wake_Up(Top : in Natural);
      entry Suspend;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Begin_Of;
      entry End_Of;
      entry Del;
      entry Overwrite;      
      entry Halt;
      entry Dialog;
      entry Refresh;
      --entry Screen_Print;
      entry Full_Screen;
   end Workstation_Process;
   type Workstation_Record(App : App_Access) is new All_Mode(Terminator) with
      record
	 Proc : Workstation_Process(Workstation_Record'Access, App);
      end record;
   
   
   -------------------------------------------------------------
   --                       Space Fighter                     --
   -------------------------------------------------------------
   --                                                         --
   --                                                         --
   --                                                         --   
   
   type Space_Fighter_Record(App : App_Access);
   task type Space_Fighter_Process (Mode : access Space_Fighter_Record; App : App_Access)  is
      pragma Storage_Size (268435456);
      --entry Initialize(App : in App_Access);
      entry Receive (Wchar : in Wide_Character);
      entry Wake_Up(Top : in Natural);
      entry Suspend;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Begin_Of;
      entry End_Of;
      entry Del;
      entry Overwrite;      
      entry Halt;
      entry Dialog;
      entry Refresh;
      --entry Screen_Print;
      entry Full_Screen;
   end Space_Fighter_Process;
   type Space_Fighter_Record(App : App_Access) is new All_Mode(Joshua) with
      record
	 Proc : Space_Fighter_Process(Space_Fighter_Record'Access, App);
      end record;
   

   
   
   -------------------------------------------------------------
   --                        Planning                         --
   -------------------------------------------------------------
   --                                                         --
   --                                                         --
   --                                                         --   
   
   type Planning_Record;
   task type Planning_Process (Mode : access Planning_Record; App : App_Access)  is
      --entry Initialize(App : in App_Access);
      entry Receive (Wchar : in Wide_Character);
      entry Wake_Up(Top : in Natural);
      entry Suspend;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Begin_Of;
      entry End_Of;
      entry Del;
      entry Overwrite;      
      entry Halt;
      entry Full_Screen;
   end Planning_Process;
   type Planning_Record(App : App_Access) is new All_Mode(Planning) with
      record
	 Proc : Planning_Process(Planning_Record'Access, App);
      end record;

   
   -------------------------------------------------------------
   --                         Manager                         --
   -------------------------------------------------------------
   --                                                         --
   --                                                         --
   --                                                         --   
   type Manager_Record(App : App_Access);
   task type Manager_Process (Mode : access Manager_Record; App : App_Access) is
      --entry Initialize(App : in App_Access);
      entry Receive (Wchar : in Wide_Character);
      entry Wake_Up(Top : in Natural);
      entry Suspend;
      
      entry Refresh;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Full_Screen;
      entry Del;
      entry Begin_Of;
      entry End_Of;
      entry Overwrite;
      --entry Screen_Print;

      entry Halt;
   end Manager_Process;
   type Manager_Record(App : App_Access) is new All_Mode(Manager) with
      record
	 Proc : Manager_Process(Manager_Record'Access, App);
      end record;

   
   -------------------------------------------------------------
   --                       MoneyBox                          --
   -------------------------------------------------------------
   --                                                         --
   --                                                         --
   --                                                         --   
   
   type Moneybox_Record(App : App_Access);
   task type MoneyBox_Process (Mode : access MoneyBox_Record; App : App_Access)  is
      --entry Initialize(App : in App_Access);
      entry Receive (Wchar : in Wide_Character);
      entry Wake_Up(Top : in Natural);
      entry Suspend;
      entry Refresh;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Begin_Of;
      entry End_Of;
      entry Del;
      entry Overwrite;      

      --entry Screen_Print;
      entry Halt;
      entry Full_Screen;
   end MoneyBox_Process;
   type MoneyBox_Record(App : App_Access) is new All_Mode(Moneybox) with
      record
	 Proc : MoneyBox_Process(MoneyBox_Record'Access, App);
      end record;

   
   -------------------------------------------------------------
   --                          Activity                       --
   -------------------------------------------------------------
   --                                                         --
   --                                                         --
   --                                                         --   
   
   type Activity_Record(App : App_Access);
   task type Activity_Process (Mode : access Activity_Record; App : App_Access)  is
      --entry Initialize(App : in App_Access);
      entry Receive (Wchar : in Wide_Character);
      entry Wake_Up(Top : in Natural);
      entry Suspend;
      entry Refresh;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Begin_Of;
      entry End_Of;
      entry Del;
      entry Overwrite;      
      --entry Screen_Print;
      entry Halt;
      entry Full_Screen;
   end Activity_Process;
   type Activity_Record(App : App_Access) is new All_Mode(Activity) with
      record
	 Proc : Activity_Process(Activity_Record'Access, App);
      end record;

   
   -------------------------------------------------------------
   --                          Stocks                         --
   -------------------------------------------------------------
   --                                                         --
   --                                                         --
   --                                                         --   
   
   type Stocks_Record(App : App_Access);
   task type Stocks_Process (Mode : access Stocks_Record; App : App_Access)  is
      --entry Initialize(App : in App_Access);
      entry Receive (Wchar : in Wide_Character);
      entry Wake_Up(Top : in Natural);
      entry Suspend;
      entry Refresh;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Begin_Of;
      entry End_Of;
      entry Del;
      entry Overwrite;      

      --entry Screen_Print;
      entry Halt;
      entry Full_Screen;
   end Stocks_Process;
   type Stocks_Record(App : App_Access) is new All_Mode(Stocks) with
      record
	 Proc : Stocks_Process(Stocks_Record'Access, App);
      end record;

   
   -------------------------------------------------------------
   --                           Bank                          --
   -------------------------------------------------------------
   --                                                         --
   --                                                         --
   --                                                         --   
   
   type Bank_Record(App : App_Access);
   task type Bank_Process (Mode : access Bank_Record; App : App_Access)  is
      --entry Initialize(App : in App_Access);
      entry Receive (Wchar : in Wide_Character);
      entry Wake_Up(Top : in Natural);
      entry Suspend;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Begin_Of;
      entry End_Of;
      entry Del;
      entry Overwrite;      
      entry Halt;
      entry Full_Screen;
   end Bank_Process;
   type Bank_Record(App : App_Access) is new All_Mode(bank) with
      record
	 Proc : Bank_Process(Bank_Record'Access, App);
      end record;

   
   -------------------------------------------------------------
   --                          Menu                           --
   -------------------------------------------------------------
   --                                                         --
   --                                                         --
   --                                                         --   
   
   type Menu_Record(App : App_Access);
   task type Menu_Process (Mode : access Menu_Record; App : App_Access)  is
      --entry Initialize(App : in App_Access);
      entry Receive (Wchar : in Wide_Character);
      entry Wake_Up(Top : in Natural);
      entry Suspend;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Begin_Of;
      entry End_Of;
      entry Del;
      entry Overwrite;      
      entry Halt;
      entry Full_Screen;
   end Menu_Process;
   type Menu_Record(App : App_Access) is new All_Mode(Menu) with
      record
	 Proc : Menu_Process(Menu_Record'Access, App);
      end record;

   
   
   -------------------------------------------------------------
   --                         Contact                         --
   -------------------------------------------------------------
   --                                                         --
   --                                                         --
   --                                                         --   
   
   type Contacts_Record(App : App_Access);
   task type Contacts_Process (Mode : access Contacts_Record; App : App_Access)  is
      --entry Initialize(App : in App_Access);
      entry Receive (Wchar : in Wide_Character);
      entry Wake_Up(Top : in Natural);
      entry Suspend;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Begin_Of;
      entry End_Of;
      entry Del;
      entry Overwrite;      
      entry Halt;
      entry Full_Screen;
   end Contacts_Process;
   type Contacts_Record(App : App_Access) is new All_Mode(Contacts) with
      record
	 Proc : Contacts_Process(Contacts_Record'Access, App);
      end record;

   
   -------------------------------------------------------------
   --                          Library                        --
   -------------------------------------------------------------
   --                                                         --
   --                                                         --
   --                                                         --   
   
   type Library_Record(App : App_Access);
   task type Library_Process (Mode : access Library_Record; App : App_Access)  is
      --entry Initialize(App : in App_Access);
      entry Receive (Wchar : in Wide_Character);
      entry Wake_Up(Top : in Natural);
      entry Suspend;
      
      entry Refresh;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Begin_Of;
      entry End_Of;
      entry Del;
      entry Overwrite;      
      --entry Screen_Print;
      entry Halt;
      entry Full_Screen;
   end Library_Process;
   
   type Library_Record(App : App_Access) is new All_Mode(Library) with
      record
	 Proc : Library_Process(Library_Record'Access, App);
      end record;
   
   
   -------------------------------------------------------------
   --                      Master/Navigation                  --
   -------------------------------------------------------------
   --                                                         --
   --                                                         --
   --                                                         --   
   
   
   type Master_Record(App : App_Access);
   task type Master_Process (Mode : access Master_Record; App : App_Access)  is
      --entry Initialize(App : in App_Access);
      entry Receive (Wchar : in Wide_Character);
      entry Wake_Up(Top : in Natural);
      entry Suspend;
      
      entry Refresh;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Begin_Of;
      entry End_Of;
      entry Del;
      entry Overwrite;      
      --entry Screen_Print;
      entry Halt;
      entry Full_Screen;
   end Master_Process;
   type Master_Record(App : App_Access) is new All_Mode(Navigation) with
      record
	 Proc : Master_Process(Master_Record'Access, App);
      end record; 
  
   
   -------------------------------------------------------------
   --                          Engine/Engineer                 --
   -------------------------------------------------------------
   --                                                         --
   --                                                         --
   --                                                         --   
   
   type Engine_Record(App : App_Access);
   task type Engine_Process (Mode : access Engine_Record; App : App_Access)  is
      --entry Initialize(App : in App_Access);
      entry Receive (Wchar : in Wide_Character);
      entry Wake_Up(Top : in Natural);
      entry Suspend;
      
      entry Refresh;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Begin_Of;
      entry End_Of;
      entry Del;
      entry Overwrite;      
      --entry Screen_Print;
      entry Halt;
      entry Full_Screen;
   end Engine_Process;
   type Engine_Record(App : App_Access) is new All_Mode(Engineer) with
      record
	 Proc : Engine_Process(Engine_Record'Access, App);
      end record; 
   
   
   --  -------------------------------------------------------------
   --  --                          Audits                        --
   --  -------------------------------------------------------------
   --  --                                                         --
   --  --                                                         --
   --  --                                                         --   
   
   type Audits_Record(App : App_Access);
   task type Audits_Process (Mode : access Audits_Record; App : App_Access)  is
      --entry Initialize(App : in App_Access);
      entry Receive (Wchar : in Wide_Character);
      entry Wake_Up(Top : in Natural);
      entry Suspend;
      
      entry Refresh;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Begin_Of;
      entry End_Of;
      entry Del;
      entry Overwrite;      
      entry Screen_Print;
      entry Halt;
      entry Full_Screen;
   end Audits_Process;
   type Audits_Record(App : App_Access) is new All_Mode(Audit) with
      record
   	 Proc : Audits_Process(Audits_Record'Access, App);
      end record;

   
   
   --  -------------------------------------------------------------
   --  --                      All_Manuals                        --
   --  -------------------------------------------------------------
   --  --                                                         --
   --  --                                                         --
   --  --                                                         --   
   
   type All_Manuals_Record(App : App_Access);
   task type All_Manuals_Process (Mode : access All_Manuals_Record; App : App_Access)  is
      --entry Initialize(App : in App_Access);
      entry Receive (Wchar : in Wide_Character);
      entry Wake_Up(Top : in Natural);
      entry Suspend;
      
      entry Refresh;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Begin_Of;
      entry End_Of;
      entry Del;
      entry Overwrite;      
      --entry Screen_Print;
      entry Full_Screen;
      entry Halt;
   end All_Manuals_Process;
   type All_Manuals_Record(App : App_Access) is new All_Mode(All_Manuals) with
      record
   	 Proc : All_Manuals_Process(All_Manuals_Record'Access, App);
      end record;
   
   --  -------------------------------------------------------------
   --  --                      Ai_Managment                        --
   --  -------------------------------------------------------------
   --  --                                                         --
   --  --                                                         --
   --  --                                                         --   
   
   --  type Computer_Record(App : App_Access);
   --  task type Computer_Process (Mode : access Computer_Record; App : App_Access)  is
   --     --entry Initialize(App : in App_Access);
   --     entry Receive (Wchar : in Wide_Character);
   --     entry Wake_Up(Top : in Natural);
   --     entry Suspend;
      
   --     entry Refresh;
   --     entry Page_Down;
   --     entry Page_Up;
   --     entry Up_Arrow;
   --     entry Down_Arrow;
   --     entry Left_Arrow;
   --     entry Right_Arrow;
   --     entry Begin_Of;
   --     entry End_Of;
   --     entry Del;
   --     entry Overwrite;      
   --     entry Screen_Print;
   --     entry Halt;
   --  end Computer_Process;
   --  type Computer_Record(App : App_Access) is new All_Mode(Agent) with
   --     record
   --  	 Proc : Computer_Process(Computer_Record'Access, App);
   --     end record;
   --  -------------------------------------------------------------
   --  --                    Self_Programming                     --
   --  -------------------------------------------------------------
   --  --                                                         --
   --  --                                                         --
   --  --                                                         --   
   
   type Self_Development_Record(App : App_Access);
   task type Self_Development_Process (Mode : access Self_Development_Record; App : App_Access)  is
      --entry Initialize(App : in App_Access);
      entry Receive (Wchar : in Wide_Character);
      entry Wake_Up(Top : in Natural);
      entry Suspend;
      
      entry Refresh;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Begin_Of;
      entry End_Of;
      entry Del;
      entry Overwrite;      
      entry Full_Screen;
      entry Halt;
   end Self_Development_Process;
   type Self_Development_Record(App : App_Access) is new All_Mode(Self_Development) with
      record
   	 Proc : Self_Development_Process(Self_Development_Record'Access, App);
      end record;
   --  -------------------------------------------------------------
   --  --                     Data_Technologies                   --
   --  -------------------------------------------------------------
   --  --                                                         --
   --  --                                                         --
   --  --                                                         --   
   
   --  type Computer_Record(App : App_Access);
   --  task type Computer_Process (Mode : access Computer_Record; App : App_Access)  is
   --     --entry Initialize(App : in App_Access);
   --     entry Receive (Wchar : in Wide_Character);
   --     entry Wake_Up(Top : in Natural);
   --     entry Suspend;
      
   --     entry Refresh;
   --     entry Page_Down;
   --     entry Page_Up;
   --     entry Up_Arrow;
   --     entry Down_Arrow;
   --     entry Left_Arrow;
   --     entry Right_Arrow;
   --     entry Begin_Of;
   --     entry End_Of;
   --     entry Del;
   --     entry Overwrite;      
   --     entry Screen_Print;
   --     entry Halt;
   --  end Computer_Process;
   --  type Computer_Record(App : App_Access) is new All_Mode(Agent) with
   --     record
   --  	 Proc : Computer_Process(Computer_Record'Access, App);
   --     end record;
   --  -------------------------------------------------------------
   --  --                          Marketing                      --
   --  -------------------------------------------------------------
   --  --                                                         --
   --  --                                                         --
   --  --                                                         --   
   
   --  type Computer_Record(App : App_Access);
   --  task type Computer_Process (Mode : access Computer_Record; App : App_Access)  is
   --     --entry Initialize(App : in App_Access);
   --     entry Receive (Wchar : in Wide_Character);
   --     entry Wake_Up(Top : in Natural);
   --     entry Suspend;
      
   --     entry Refresh;
   --     entry Page_Down;
   --     entry Page_Up;
   --     entry Up_Arrow;
   --     entry Down_Arrow;
   --     entry Left_Arrow;
   --     entry Right_Arrow;
   --     entry Begin_Of;
   --     entry End_Of;
   --     entry Del;
   --     entry Overwrite;      
   --     entry Screen_Print;
   --     entry Halt;
   --  end Computer_Process;
   --  type Computer_Record(App : App_Access) is new All_Mode(Agent) with
   --     record
   --  	 Proc : Computer_Process(Computer_Record'Access, App);
   --     end record;

   
   
   
   
   
   --  -------------------------------------------------------------
   --  --                          Computer                        --
   --  -------------------------------------------------------------
   --  --                                                         --
   --  --                                                         --
   --  --                                                         --   
   
   --  type Computer_Record(App : App_Access);
   --  task type Computer_Process (Mode : access Computer_Record; App : App_Access)  is
   --     --entry Initialize(App : in App_Access);
   --     entry Receive (Wchar : in Wide_Character);
   --     entry Wake_Up(Top : in Natural);
   --     entry Suspend;
      
   --     entry Refresh;
   --     entry Page_Down;
   --     entry Page_Up;
   --     entry Up_Arrow;
   --     entry Down_Arrow;
   --     entry Left_Arrow;
   --     entry Right_Arrow;
   --     entry Begin_Of;
   --     entry End_Of;
   --     entry Del;
   --     entry Overwrite;      
   --     entry Screen_Print;
   --     entry Halt;
   --  end Computer_Process;
   --  type Computer_Record(App : App_Access) is new All_Mode(Agent) with
   --     record
   --  	 Proc : Computer_Process(Computer_Record'Access, App);
   --     end record;
   type Frame_Record is tagged
      record
	 Style : Style_Enum := Color_And_Color;
	 Color : Color_Type := White;
	 L   : Line_Range := 1;
	 C   : Column_Range := 1;
	 H   : Line_Range := 67;
	 W   : Column_Range := 240;
	 Win : Windows.Window_record;
      end record;
   
   
   type Docume_Record is tagged
      record
	 Title    : OS_Lib.String_Access; --
	 Filename : OS_Lib.String_Access; --
	 Fullpath : OS_Lib.String_Access;
	 Unit     : OS_Lib.String_Access; --
	 Creation_Date : Time; --
	 Last_Edition  : Time; --
	 Openned       : Boolean := False; --
	 Is_New_Doc    : Boolean := False;
	 Size          : natural := 0;
	 Owner         : OS_Lib.String_Access;
      end record;
   
   type Docume_Access is access all Docume_Record;
   
   procedure Docume_Free (Docume : in out Docume_Access);   

   
   
   type Devel_Record(App : App_Access);
   task type Devel_Process (Mode : access Devel_Record; App : App_Access) is
      --entry Initialize(App : in App_Access);
      entry Receive (Wchar : in Wide_Character);
      entry Halt;
      entry Suspend;
      entry Wake_Up(Top : in Natural);
      entry Refresh;
      entry Page_Up;
      entry Page_Down;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Full_Screen;

      entry Del;

      entry Begin_Of;

      entry End_Of;
      
      entry Overwrite;

      
   end Devel_Process;
   type Devel_Record(App : App_Access) is new All_Mode(Devel) with
      record
	 State : Boolean := False;
	 Logged : Boolean := False;
   	 Proc : Devel_Process(Devel_Record'Access, App);	    
      end record;

   
   -------------------------------------------------------------
   --                          WOPR                        --
   -------------------------------------------------------------
   --                                                         --
   --                                                         --
   --                                                         --   
   
   type WOPR_Record(App : App_Access);
   task type WOPR_Process (Mode : access WOPR_Record; App : App_Access)  is
      --entry Initialize(App : in App_Access);
      entry Receive (Wchar : in Wide_Character);
      entry Wake_Up(Top : in Natural);
      entry Suspend;
      
      entry Refresh;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Begin_Of;
      entry End_Of;
      entry Del;
      entry Overwrite;      
      entry Screen_Print;
      entry Halt;
   end WOPR_Process;
   
   type WOPR_Record(App : App_Access) is new All_Mode(Admin) with
      record
	 Proc : WOPR_Process(WOPR_Record'Access, App);
      end record;
   
   
      -------------------------------------------------------------
   --                          Entreprise                     --
   -------------------------------------------------------------
   --                                                         --
   --                                                         --
   --                                                         --   
   
   type Person_Record(App : App_Access);
   task type Person_Process (Mode : access Person_Record; App : App_Access)  is
      --entry Initialize(App : in App_Access);
      entry Receive (Wchar : in Wide_Character);
      entry Wake_Up(Top : in Natural);
      entry Suspend;
      
      entry Refresh;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Begin_Of;
      entry End_Of;
      entry Del;
      entry Overwrite;      
      entry Screen_Print;
      entry Halt;
   end Person_Process;
   
   type Person_Record(App : App_Access) is new All_Mode(Entreprise) with
      record
	 Proc : Person_Process(Person_Record'Access, App);
      end record;

   -------------------------------------------------------------
   --                          Shell_Interface                --
   -------------------------------------------------------------
   --                                                         --
   --                                                         --
   --                                                         --   
   
   type Shell_Record(App : App_Access);
   task type Shell_Process (Mode : access Shell_Record; App : App_Access)  is
      --entry Initialize(App : in App_Access);
      entry Receive (Wchar : in Wide_Character);
      entry Wake_Up(Top : in Natural);
      entry Suspend;
      
      entry Refresh;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Begin_Of;
      entry End_Of;
      entry Del;
      entry Overwrite;      
      entry Screen_Print;
      entry Halt;
   end Shell_Process;
   
   type Shell_Record(App : App_Access) is new All_Mode(Shell_interface) with
      record
	 Proc : Shell_Process(Shell_Record'Access, App);
      end record;
   
   
   
   
   
   
   
   type World_Record(App : App_Access);
   
   task type Conductor_Process (Mode : access World_Record; App : App_Access)  is
      --entry Initialize(App : in App_Access);
      entry Receive (Wchar : in Wide_Character);
      entry Wake_Up(Top : in Natural);
      entry Suspend;
      
      entry Refresh;
      entry Page_Down;
      entry Page_Up;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Begin_Of;
      entry End_Of;
      entry Del;
      entry Overwrite;      
      entry Screen_Print;
      entry Halt;
   end Conductor_Process;
   
   type World_Record(App : App_Access) is new All_Mode(Process) with
      record
	 Proc : Conductor_Process(World_Record'Access, App);
      end record;
         Alphabet : constant Wide_String := "aàâäeéèêëiïîoôuùybcdfghjklmnpqrstvwxz.;?!'_ -";   



      type Gate_Record(App : App_Access);
   task type Gate_Process (Mode : access Gate_Record; App : App_Access) is
      entry Receive (Wchar : in Wide_Character);
      entry Halt;
      entry Suspend;
      entry Wake_Up(Top : in Natural);
      entry Refresh;
      entry Page_Up;
      entry Page_Down;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Full_Screen;

      entry Del;

      entry Begin_Of;

      entry End_Of;
      
      entry Overwrite;

      entry Screen_Print;
   end Gate_Process;
   
   type Gate_Record(App : App_Access) is new All_Mode(Gate) with
      record
   	 Proc : Gate_Process(Gate_Record'Access, App);	    
      end record;

   
   type Auth_Record(App : App_Access);
   task type Auth_Process (Mode : access Auth_Record; App : App_Access) is
      entry Auth;
      entry Receive (Wchar : in Wide_Character);
      entry Halt;
      entry Suspend;
      entry Wake_Up(Top : in Natural);
      entry Refresh;
      entry Page_Up;
      entry Page_Down;
      entry Up_Arrow;
      entry Down_Arrow;
      entry Left_Arrow;
      entry Right_Arrow;
      entry Full_Screen;

      entry Del;

      entry Begin_Of;

      entry End_Of;
      
      entry Overwrite;

      entry Screen_Print;
   end Auth_Process;
   
   type Auth_Record(App : App_Access) is new All_Mode(Auth) with
      record
   	 Proc : Auth_Process(Auth_Record'Access, App);	    
      end record;

   
      
   use Windows ;
   
   type Accounting_Windows_Type is
      record
	 Voice_Num_Win     : Window_Record;
	 Acc_Num_Win       : Window_Record;
	 Total_Ht_Win      : Window_Record;
	 Total_TVA_Win     : Window_Record;
	 Total_TTC_Win     : Window_Record;
	 Date_Win          : Window_Record;
	 Peer_Win          : Window_Record;	 
      end record;   
   
   type Ticket_Windows_Type is
      record
	 Line_Num_Win      : Window_Record;
	 Description_Win   : Window_Record;
	 Unit_Ht_Win       : Window_Record;
	 Quantity_Win      : Window_Record;
	 Total_Ht_Win      : Window_Record;
	 TVA_Win           : Window_Record;
	 Total_TVA_Win     : Window_Record;
	 Total_TTC_Win     : Window_Record;
      end record;   
   
   type stock_Windows_Type is
      record
	 stock_Num_Win     : Window_Record;
	 Name_Win          : Window_Record;
	 Quantity_Win      : Window_Record;
	 Unit_Ht_Win       : Window_Record;
	 TVA_Win           : Window_Record;

      end record;   
   
   
   
   
   
   type Agence_Record is new Engineering_Record with 
      record
	 Lines         : Line_Range := 67;
	 Columns       : Column_Range := 240;
	 Term    : Term_Enum := Linux;
	 Mode    : Mode_Enum := Auth;
	 Desktop : Mode_Array(1..2);
	 Console : Console_Process (Agence_Record ' access);
	 
	 On_Esc : Boolean := False;
	 
	 ------------------------------------------------------------
	 --               Neural network
	 Wline            : Wide_String_Access := new Wide_String ' ("");
	 Wbuffer          : Wide_String_Access;
	 Current_Pos      : Natural := 1;      
	 Wline_Length     : Natural := 0;
	 Word_Number      : El.Word_Range := 0;
	 Dialog_Response  : Wide_String_Access := new Wide_String ' ("");
	 Response_Buffer  : Wide_Set(1); 
	 Internal         : Wide_String_Access := new Wide_String ' ("");
	 internal_Buffer  : Wide_Set(1); 
	 
	 Set_Filename : access String := new String ' ("samples_set.txt");
	 
	 Input            : Neural_Retrain.Input_Type;
	 Output           : Neural_Retrain.Output_Type;
	 Feedback         : Neural_Retrain.Output_Type;-- := String2input(To_String(Preuve));
	 Samples_Set      : aliased Neural_Train.Sample_Set_Type;
	 Samples          : aliased Neural_Retrain.Sample_Set_Type;
	 Words            : Glossary.Glossary_Type;
	 Frames           : Frame_Set;
	 
	 ------------------------------------------------------------
	 --                 Money Box
	 
	 Ticket_Wins       : Ticket_Windows_Type;
	 
	 ------------------------------------------------------------
	 --                 Stocks
	 
	 Stocks_Wins       : Stock_Windows_Type;
	 
	 ------------------------------------------------------------
	 --                Activity
	 
	 Activity_Wins     : Accounting_Windows_Type;
	 
	 
	 
	 Initialized       : Boolean := False;
	 
	 
	 
	 ------------------------------------------------------------
	 --                     Entreprise	 
	 Self : Terminal_Type;
	 View_Wins         : Accounting_Windows_Type;
	 Created           : Boolean := False;
	 
	 ------------------------------------------------------------
	 --                Library
	 Rented, Backed, Owner : Classes.Abstract_Access;
	 List                  : Classes.Abstract_Vectors.vector;
	 
	 ------------------------------------------------------------
	 --                  Bank
	 Bank : Account_Manager;
	 
	 
	 
	 ------------------------------------------------------------
	 --                    Devel/Editor                        --
	 Left_View        : Frame_Record;
	 Buffer           : Frame_Record;
	 Document         : Frame_Record;
	 Doc_States       : Frame_Record;
	 Doc_Initialized  : Boolean := False;
	 Current_Doc      : Docume_Access;
	 
	 
	 Visitors      : User_set(4);	 
	 User_Auth     : Logon_Record;
	 User          : User_Access;
	 User_Ready    : Boolean := False;
	 User_Path     : Os_Lib.String_Access;
	 Full_Shell_Filename : Os_Lib.String_Access;
	 ------------------------------------------------------------
	 --                    Devel/Processing                    --	 
	 --Target : Target_Access;
	 Command : OS_Lib.String_Access;
	 Err      : Frame_Record;
	 Cmd      : Frame_Record;
	 Cmd_Result : Frame_Record;

	 
	 ------------------------------------------------------------
	 --                   Server
	 Started  : Boolean := False;
	 
	 ------------------------------------------------------------
	 --                   Web
	 Web_Result : aliased Results.Search_Result_Record;
	 index_Result : aliased Results.Search_Result_Record;
      end record;
   
   
   procedure Restore(T : in out Terminal_Type;
   		     Filename : in String);
   
   
   
   
   App    : aliased Agence_Record;
   
   
   package Servers is new M.Servers (Engineering, Engineering_Record(App)'Access);
   use Servers;
   
   
   Functions : Mode_Array(0..37);
end M.Agence ;