/*****************************************************************************
 * 
 * name         : notify.c
 * description      : handle the notify intuition library
 * version        : 1.3
 *
 * created        : ?
 * last change      : 05-06-99
 *
 *****************************************************************************
 */
#include <libraries/notifyintuition.h>
#include <exec/memory.h>

#include <proto/exec.h>
#include <proto/intuition.h>
#include <string.h>
#include <stdio.h>
#include "utils.h"
#include <clib/rtracker_protos.h>
#include <pragmas/rtracker_pragmas.h>
#include <intuition/screens.h>

extern struct Library * RTrackerBase ;
extern struct Library * NotifyIntuitionBase ;



int startNotify(idWin * prj) {
  /* initialise notification
   */
  UBYTE defPubScrName[MAXPUBSCREENNAME] ;
  int ret = FALSE ;


//  GetDefaultPubScreen(defPubScrName) ;

  
  if ((prj->Notify->inr_Name  = NewAllocVec(strlen(prj->backWin.PubScreen), MEMF_PUBLIC)) != NULL) {
    if ((prj->notifyPort      = NewCreateMsgPort()) != NULL) {
      strcpy(prj->Notify->inr_Name, prj->backWin.PubScreen) ;
      prj->Notify->inr_Flags  = INRF_SEND_MESSAGE|INRF_WAIT_REPLY|INRF_BEFORE_CLOSEWORKBENCH|INRF_AFTER_OPENWORKBENCH ;
      prj->Notify->inr_stuff.inr_Msg.inr_Port = prj->notifyPort ;
      prj->Notify->inr_Pri                    = 101 ;

      prj->Notify->inr_UniqueID               = 0x4d59434c ;
      NotIStartNotify(prj->Notify) ;
      ret = TRUE ;
    }
  }
  return(ret) ;
}

void endNotify(idWin * prj) {
  /* terminate notification
   */
  if (prj->Notify)           NotIEndNotify(prj->Notify) ;
  if (prj->notifyPort)       NewDeleteMsgPort(prj->notifyPort) ; 
  if (prj->Notify->inr_Name) NewFreeVec(prj->Notify->inr_Name) ;
}
