--------------------------------------------------------------------------------
--                                                                            --
-- Copyright (C) 2004, RISC OS Ada Library (RASCAL) developers.               --
--                                                                            --
-- This library is free software; you can redistribute it and/or              --
-- modify it under the terms of the GNU Lesser General Public                 --
-- License as published by the Free Software Foundation; either               --
-- version 2.1 of the License, or (at your option) any later version.         --
--                                                                            --
-- This library 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           --
-- Lesser General Public License for more details.                            --
--                                                                            --
-- You should have received a copy of the GNU Lesser General Public           --
-- License along with this library; if not, write to the Free Software        --
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    --
--                                                                            --
--------------------------------------------------------------------------------

-- @brief OLE related types and methods.
-- $Author$
-- $Date$
-- $Revision$

with System.Unsigned_Types;

with RASCAL.OS;      use RASCAL.OS;

package RASCAL.OLE is

   type OLE_Message_Type is (Try_Edit,Run_And_Edit,ReEdit);

   -- Pathname is only valid if Message_Kind is Try_Edit
   --
   type Message_OLEFileChanged is
   record
   Header         : Message_Event_Header;
   Message_Kind   : OLE_Message_Type;
   Session_Number : Integer;
   Pathname       : Char_Array(1..228);
   end record;

   pragma Convention (C, Message_OLEFileChanged);

   type Message_OLEFileChanged_Pointer is access Message_OLEFileChanged;

   type AMEL_Message_OLEFileChanged is abstract new
        Message_EventListener(Message_Event_OLE_FileChanged) with
   record
   Event : Message_OLEFileChanged_Pointer;
   end record;

   --
   -- This message requests a server to edit some data.
   --The normal procedure is to use message_Type Try_Edit initially, then if that bounces Run_And_Edit.
   --If the server already exists, ReEdit is used.
   --Filetype and pathname are only valid if message_kind is not reedit.
   --
   type Message_OLEOpenSession is
   record
   Header         : Message_Event_Header;
   Unique_Name    : Char_Array(1..16);
   Window_Handle  : Wimp_Handle_Type;
   X_Coordinate   : Integer;
   Y_Coordinate   : Integer;
   Message_Kind   : OLE_Message_Type;
   Session_Number : Integer;
   File_Type      : Integer;
   Pathname       : Char_Array(1..196);
   end record;

   pragma Convention (C, Message_OLEOpenSession);

   type Message_OLEOpenSession_Pointer is access Message_OLEOpenSession;

   type AMEL_Message_OLEOpenSession is abstract new
        Message_EventListener(Message_Event_OLEOpenSession) with
   record
   Event : Message_OLEOpenSession_Pointer;
   end record;

   --
   -- The OLE server replies to OLE_OpenSession by changing message_id to OLE_OpenSessionAck, setting your_ref = my_ref, and sending it back.
   --Client then knows which task is editing its file.
   --It is returned in reply to an OLEOpenSession message. Server has loaded file, and has established the link.
   --Filetype and pathname are only valid if message_kind is not reedit.
   --
   type Message_OLEOpenSessionAck is
   record
   Header         : Message_Event_Header;
   Unique_Name    : Char_Array(1..16);
   Window_Handle  : Wimp_Handle_Type;
   X_Coordinate   : Integer;
   Y_Coordinate   : Integer;
   Message_Kind   : OLE_Message_Type;
   Session_Number : Integer;
   File_Type      : Integer;
   Pathname       : Char_Array(1..196);
   end record;

   pragma Convention (C, Message_OLEOpenSessionAck);

   type Message_OLEOpenSessionAck_Pointer is access Message_OLEOpenSessionAck;

   type AMEL_Message_OLEOpenSessionAck is abstract new
        Message_EventListener(Message_Event_OLEOpenSessionAck) with
   record
   Event : Message_OLEOpenSessionAck_Pointer;
   end record;

   --
   -- This message informs one or all clients that one or all of the servers sessions are terminated (Task quit or click on close window).
   --
   type Message_OLECloseSession is
   record
   Header         : Message_Event_Header;
   Message_Kind   : OLE_Message_Type;
   Session_Number : Integer;
   end record;

   pragma Convention (C, Message_OLECloseSession);

   type Message_OLECloseSession_Pointer is access Message_OLECloseSession;

   type AMEL_Message_OLECloseSession is abstract new
        Message_EventListener(Message_Event_OLECloseSession) with
   record
   Event : Message_OLECloseSession_Pointer;
   end record;

end RASCAL.OLE;
