#ifndef LIBRARIES_NOTIFYINTUITION_H
#define LIBRARIES_NOTIFYINTUITION_H

/*
**      $VER: notifyintuition.i 2.40 (01.06.96)
**      Includes Release 40.15
**
**      Definitions for the notifyintuition library base
**
**      (C) Copyright 1994-96 Hans-W. Schober <chef@connect.gun.de>
**          All Rights Reserved
**
**      Include file for MaxonC++ (c) by Maik "BLiZZeR" Schreiber
**                                    <sysop@fodder.insider.sub.de>
*/


#ifndef EXEC_PORTS_H
#include <exec/ports.h>
#endif

#ifndef EXEC_TASKS_H
#include <exec/tasks.h>
#endif


/* === library definitions ============================================= */
#define NOTIFYINTUITIONNAME  "notifyintuition.library"
#define NOTIFYINTUITION_VMIN 2


/* === definitions =====================================================
   ------ IntNotifyRequest ---------------------------------------------
   Do not send to dos.library :-)
*/
struct IntNotifyRequest
{
  UBYTE *inr_Name;          /* Application sets this Pattern/Name
                               like (WORKBENCH|DOPUS#?)                   */
  UBYTE *inr_Tokenstring;   /* Tokenstring created by notifyintuition.lib */
  ULONG  inr_UserData;      /* for the application's use                  */
  ULONG  inr_Flags;         /* see below                                  */

  /* -- inr_Msg: */
  union
  {
    struct
    {
      struct Task    *inr_Task;   /* struct Task * for SEND_SIGNAL        */
    } inr_Signal;
    struct
    {
      struct MsgPort *inr_Port;   /* struct MsgPort * for SEND_MESSAGE    */
    } inr_Msg;
    struct
    {
      APTR            inr_Hook;   /* notify.lib used your Entrypoint * for
                                     USE_HOOK                             */
    } inr_Hook;
  } inr_stuff;

  /* -- inr_Signal: */
  UBYTE  inr_SignalNum;     /* for SEND_SIGNAL                            */
  BYTE   inr_Error;         /* An Error occured during NotIStartNotify()/
                               NotIEndNotify()                            */
  BYTE   inr_Pri;           /* Set your priority on NotIStartNotify()     */
  BYTE   inr_pad;

  /* -- Unique: */
  ULONG  inr_UniqueID;      /* Make your tools sensetive to run only one
                               of it                                      */

  /* -- Reserved fields: */
  ULONG  inr_Reserved[3];   /* I need it                                  */

  /* -- internal for use by handlers */
  ULONG  inr_MsgCount;      /* # of outstanding msgs                      */
  APTR   inr_ReqSemaphore   /* Semaphore created by NotIStartNotify(),
                            Use AttemptSemaphore(), if you want no msg now */
};


/* ------ IntNotifyMessage ----------------------------------------------
   Sent to the application if SEND_MESSAGE is specified.
   Pointer in A1 if USE_HOOK is specified.
*/

struct IntNotifyMessage
{
  struct Message inm_Message;
  ULONG          inm_Class;
  UWORD          inm_Code;
  struct IntNotifyRequest *inm_NReq; /* Your STRUCT(IntNotifyRequest)
                                    don't modify the request!              */
  APTR           inm_IntObject;  /* IntuitionObject like Screen or Window
                                    you wish reported to                   */
  APTR           inm_TagListPtr; /* from OpenWindow/OpenScreen(TagList)
                                    You can modify or set the taglist in this
                                    message for use BEFORE_OPENWINDOW or
                                    BEFORE_OPENSCREEN with WAIT_REPLY or
                                    USE_HOOK !!                            */
  struct Task   *inm_Task;       /* Taskaddress from caller                */
  ULONG          inm_DoNotTouch1;
};


/* Do not modify or reuse the IntNotifyRequest while it is active. */


/* ------ IntNotifyMessage Class ---------------------------------------- */
#define INTNOTIFY_CLASS 0x43210000


/* ------ IntNotifyRequest Flags ---------------------------------------- */
/* put your msg_Port in inr_Port */
#define INRF_SEND_MESSAGE                (1L <<  0)

/* put Taskaddress in inr_Task, it will wake up */
#define INRF_SEND_SIGNAL                 (1L <<  1)

/* Your entrypoint is used on notify
   A0=Hookaddress A1=STRUCT (IntNotifyMessage)
   A2=STRUCT (IntNotifyRequest)
   no need to restore Registers after call  */
#define INRF_USE_HOOK                    (1L <<  2)

/* If SEND_MESSAGE then notify.lib will
   wait for your reply               */
#define INRF_WAIT_REPLY                  (1L <<  4)

/* You get an initial notifymsg/signal/hook */
#define INRF_NOTIFY_INITIAL              (1L <<  5)

/* a screen will be opened. Set or modify the TagList */
#define INRF_BEFORE_OPENSCREEN           (1L <<  6)

/* If screen is now open */
#define INRF_AFTER_OPENSCREEN            (1L <<  7)

/* The screen will be closed */
#define INRF_BEFORE_CLOSESCREEN          (1L <<  8)

/* There is allready closed a window on the screen
   Only if _NOT_ your window. So SEND_MESSAGE!WAIT_REPLY no risc */
#define INRF_AFTER_CLOSEWINDOW_ON_SCREEN (1L <<  9)

/* PubScreenStatus is changed */
#define INRF_AFTER_PUBSCREENMODE         (1L << 10)

/* a window will be opened. Set or modify the TagList */
#define INRF_BEFORE_OPENWINDOW           (1L << 11)

/* Notify for a window. Pattern of name in inr_Name */
#define INRF_AFTER_OPENWINDOW            (1L << 12)

/* Specified window will close now */
#define INRF_BEFORE_CLOSEWINDOW          (1L << 13)

/* If Workbench is open now */
#define INRF_AFTER_OPENWORKBENCH         (1L << 14)

/* Workbench will close now */
#define INRF_BEFORE_CLOSEWORKBENCH       (1L << 15)

/* PubScreenName (inm_TagListPtr) will locked now,
   you can open the screen now, if not available yet */
#define INRF_BEFORE_LOCKPUBSCREEN         (1L << 16)

#define INRF_AFTER_SCREENTOFRONT         (1L << 17)

#define INRF_AFTER_SCREENTOBACK          (1L << 18)

/* does not report the actions caused by you */
#define INRF_NOT_MYOWNREQUEST            (1L << 23)


/* If no inr_Name given, all screens/windows would be reportet */


/* Flags reserved for private use by the notifyintuition.library: */
#define INR_LIBRARY_FLAGS   0xff000000


/* ------ IntNotifyMessage Code ----------------------------------------- */
#define INRCODE_BEFORE_OPENSCREEN     0x0001
#define INRCODE_AFTER_OPENSCREEN      0x0002
#define INRCODE_BEFORE_CLOSESCREEN    0x0004
#define INRCODE_AFTER_CLOSEWINSCREEN  0x0008
#define INRCODE_AFTER_CHANGEPUBMODE   0x0010
#define INRCODE_BEFORE_OPENWINDOW     0x0020
#define INRCODE_AFTER_OPENWINDOW      0x0040
#define INRCODE_BEFORE_CLOSEWINDOW    0x0080
#define INRCODE_AFTER_OPENWORKBENCH   0x0100
#define INRCODE_BEFORE_CLOSEWORKBENCH 0x0200
#define INRCODE_BEFORE_LOCKPUBSCREEN  0x0400
#define INRCODE_AFTER_SCREENTOFRONT   0x0800
#define INRCODE_AFTER_SCREENTOBACK    0x1000


/* ------ IntNotifyError Codes ------------------------------------------ */
/* This ID is already runnig */
#define INRERROR_UNIQUE             98

/* SEND_MESSAGE ? SEND_SIGNAL ? USE_HOOK */
#define INRERROR_NOFLAGS            99

/* for SEND_MESSAGE it must be a MsgPort (LN_TYPE==NT_MSGPORT)
   for SEND_SIGNAL it must be a Process (LN_TYPE==NT_PROCESS)  */
#define INRERROR_WRONGTYPE         100

/* no Signal given. Do not use NULL */
#define INRERROR_NOSIGNAL          101

/* define your MsgType you want */
#define INRERROR_NOTHINGTODO       102

/* No Memory available */
#define INRERROR_LOWMEM            103

/* Clean up your MsgPort */
#define INRERROR_OUTSTANDING_MSGS   -1

/* eg. cant free it while locked */
#define INRERROR_ISLOCKED           -2

/* is not started with NotIStartNotify() */
#define INRERROR_UNKNOWN            -3

/* Notify allready startet */
#define INRERROR_INUSE              -4


/* === library functions =============================================== */
#ifdef __cplusplus
#define CPLUSPLUSON
#pragma -
#endif

struct IntNotifyRequest *NotIStartNotify(struct IntNotifyRequest *);
struct IntNotifyRequest *NotIEndNotify(struct IntNotifyRequest *);
struct Task             *NotIFindUniqueTask(ULONG);

#pragma amicall(NotifyIntuitionBase, 0x1e, NotIStartNotify(a0))
#pragma amicall(NotifyIntuitionBase, 0x24, NotIEndNotify(a0))
#pragma amicall(NotifyIntuitionBase, 0x2a, NotIFindUniqueTask(d0))

#ifdef CPLUSPLUSON
#undef CPLUSPLUSON
#pragma +
#endif


#endif   /* LIBRARIES_NOTIFYINTUITION_H */
