@colinw
The app has two static notifications and one dynamic. Using two different message ports. One for static ones, the other for the dynamic.
Th static ones are predefined files that are initiated and started at startup and deallocated once the program quits.
The dynamic listens to a directory and changes every time the user selects a new directory.
Dynamic allocations.
FilerInstance->notreq = IDOS->AllocDosObjectTags(DOS_NOTIFYREQUEST,
ADO_NotifyName, path,
ADO_NotifyMethod, NRF_SEND_MESSAGE,
//ADO_DOSMethodOnly, TRUE,
ADO_NotifyPort, NotPort,
ADO_NotifyInitial, FALSE,
TAG_DONE);
if(FilerInstance->notreq)
{
IDOS->StartNotify(FilerInstance->notreq);
}
Dynamic deallocation.
struct Message *msg;
if(FilerInstance->notreq!=NULL)
{
// Flush any outstanding messages
while ( (msg=IExec->GetMsg(NotPort)) )
{
IExec->ReplyMsg((struct Message *)msg);
}
IDOS->EndNotify(FilerInstance->notreq);
}
Static allocation:
FilerInstance->dstreq = IDOS->AllocDosObjectTags(DOS_NOTIFYREQUEST,
ADO_NotifyName, FILER_DST_ID,
ADO_NotifyMethod, NRF_SEND_MESSAGE,
//ADO_DOSMethodOnly, TRUE,
ADO_NotifyPort, DstPort,
ADO_NotifyInitial, FALSE,
TAG_DONE);
if(FilerInstance->dstreq)
{
IDOS->StartNotify(FilerInstance->dstreq);
}
FilerInstance->cfgreq = IDOS->AllocDosObjectTags(DOS_NOTIFYREQUEST,
ADO_NotifyName, FILER_CFG_ID,
ADO_NotifyMethod, NRF_SEND_MESSAGE,
//ADO_DOSMethodOnly, TRUE,
ADO_NotifyPort, DstPort,
ADO_NotifyInitial, FALSE,
TAG_DONE);
if(FilerInstance->cfgreq)
{
IDOS->StartNotify(FilerInstance->cfgreq);
}
static deallocation:
struct Message *msg;
// Flush any outstanding messages
while ( (msg=IExec->GetMsg(DstPort)) )
{
IExec->ReplyMsg((struct Message *)msg);
}
if(FilerInstance->dstreq!=NULL)
{
IDOS->EndNotify(FilerInstance->dstreq);
}
if(FilerInstance->cfgreq!=NULL)
{
IDOS->EndNotify(FilerInstance->cfgreq);
}