void MCSystemRequestUserAttention(void)
{
	if (s_bounce_nmr != nil)
		MCSystemCancelRequestUserAttention();
	
	bool t_success;
	t_success = true;
	
	if (t_success)
		t_success = MCMemoryNew(s_bounce_nmr);
	
	if (t_success)
	{
		s_bounce_nmr -> nmMark = 1;
		s_bounce_nmr -> qType = nmType;
		if (NMInstall(s_bounce_nmr) != noErr)
			t_success = false;
	}
	
	if (!t_success)
	{
		MCMemoryDelete(s_bounce_nmr);
		s_bounce_nmr = nil;
	}
}
void MacDock::startBounce()
{
	if (!isBouncing) {
		bounceRec.qType = nmType;
		bounceRec.nmMark = 1;
		NMInstall(&bounceRec);
		isBouncing = true;
	}
}
Exemple #3
0
OSStatus
PostEventSIH( void* p1, void* p2 )
{
    DVCEventRecordPtr			pEvent = (DVCEventRecordPtr) p1;
    DVEventEntryPtr				pEventEntry;
    DVNotificationEntryPtr		pEntry;
    OSErr						error = noErr;

    // We now have two broad classifications of events - ones that need to be
    // reported ASAP, which are stream related:
    //
    // 		kDVIsochReadComplete
    //		kDVIsochWriteComplete
    //
    // and ones that are device management related, whose notifications will
    // probably generate massive amounts of task-level only Toolbox calls:
    //
    //		kDVDeviceAdded
    //		kDVDeviceRemoved
    //		kDVIsochReadEnabled
    //		kDVIsochReadDisabled
    //		kDVIsochWriteEnabled
    //		kDVIsochWriteDisabled
    //
    // We ship the low-latency notifications to secondary interrupt, while
    // the task level calls we queue and get back to them when someone
    // calls DVIdle().
    //

    // ok, so let's go find out who's waiting for this event

    // go through list looking for the curious
    pEntry = (DVNotificationEntryPtr) gpFamilyGlobals->notificationQueue->qHead;
    while ( pEntry != nil )
    {
        if ( (pEvent->eventHeader.theEvent & pEntry->wantedEvents) != nil )
        {
            // only send notification if it's a global connection id or if
            // the event came from the same deviceID as this notif entry
            if ( (pEntry->deviceID == kDVGlobalEventConnectionID) ||
                    (pEvent->eventHeader.deviceID == pEntry->deviceID) )
            {
                // we currently only support a one-shot notification, like clock callbacks
                pEntry->wantedEvents = nil;

                // make sure the event contains this notification id
                pEvent->eventHeader.notifID = (DVCNotificationID) pEntry;


                // check before calling..
                switch( pEvent->eventHeader.theEvent )
                {
                case kDVIsochReadComplete:
                case kDVIsochWriteComplete:
                    // process event immediately...
                    error = (*pEntry->notifyProc)( pEvent, pEntry->userRefCon );
                    break;

                case kDVDeviceAdded:
                case kDVDeviceRemoved:
                case kDVIsochReadEnabled:
                case kDVIsochReadDisabled:
                case kDVIsochWriteEnabled:
                case kDVIsochWriteDisabled:
                    // queue the event and proc for later processing...

                    // get an entry
                    error = PBDequeueFirst( gpFamilyGlobals->availableDVEvents,
                                            (QElemPtr*) &pEventEntry );

                    // if we don't have any more available event elements,
                    // we just drop the events on the floor

                    // copy the notify proc & refcon
                    if ( error == noErr )
                    {
                        pEventEntry->notifyProc	= pEntry->notifyProc;
                        pEventEntry->userRefCon = pEntry->userRefCon;
                    }

                    // copy the event
                    if ( error == noErr )
                        BlockCopy( pEvent, &(pEventEntry->eventRec), sizeof( DVCEventRecord ) );

                    // queue it
                    if ( error == noErr )
                        PBEnqueue( (QElemPtr) pEventEntry, gpFamilyGlobals->receivedDVEvents );

                    // If we haven't already sent notification
                    // to Notification Mgr to run tasks, do it now...
                    if ( CompareAndSwap( false, true, &(gpFamilyGlobals->nmIsInstalled) ) )
                        NMInstall( &(gpFamilyGlobals->dvNMRec) );

                    break;

                default:
                    break;
                }

            }
        }

        // next entry
        pEntry = (DVNotificationEntryPtr) pEntry->qLink;
    }

    return( error );
}
Exemple #4
0
boolean notifyuser (bigstring bsmessage) {
	
	/*
	use the Notification Manager to ask the user to bring our app to the front.
	
	note that we must allocate the record in the heap because multi-threading 
	makes stack addresses non-persistent.
	
	1/18/93 dmb: langbackgroundtask now takes flresting parameter; don't set global
	
	6/9/93 dmb: don't ignore the result of the background callbacks
	
	2.1b5 dmb: if we're in the main thread, need to do same as if yield is disabled.

	7.0d6 PBS: In Pike, the header of the dialog should not read UserLand Frontier,
	it should be UserLand [Whatever]. At this writing, [Whatever] is still undefined,
	so we'll go with Whatever for the moment.
	*/
	
#ifdef MACVERSION

	NMRecPtr pb;
	tyiconfamily icons;
	OSErr errcode;
	boolean fl = true;

	#define systemevents (osMask | updateMask | activMask | highLevelEventMask)

	#if TARGET_API_MAC_CARBON == 1
	
		{
		
			SInt16 itemhit = 0;
			OSErr err = noErr;
			
			err = StandardAlert (kAlertNoteAlert, bsmessage, nil, nil, &itemhit);
	
			return (err == noErr);
		}
	
	#endif
	
	pb = (NMRecPtr) NewPtrClear (longsizeof (NMRec));
	
	if (pb == nil)
		return (false);
	/*
	clearbytes (&pb, longsizeof (pb));
	*/
	
	(*pb).qType = nmType;
	
	(*pb).nmMark = 1;
	
	clearbytes (&icons, longsizeof (icons));
	
	icons.hics1 = GetResource ('ics#', 128);
	
	icons.hics4 = GetResource ('ics4', 128);
	
	icons.hics8 = GetResource ('ics8', 128);
	
	newfilledhandle (&icons, longsizeof (tyiconfamily), &(*pb).nmIcon);
	
	(*pb).nmSound = (Handle) -1;
	
	if (isemptystring (bsmessage))
		(*pb).nmStr = nil;
	
	else {
		(*pb).nmStr = (StringPtr) NewPtr (stringsize (bsmessage));
		
		copystring (bsmessage, (*pb).nmStr);
		}
	
	(*pb).nmResp = nil;
	
	errcode = NMInstall (pb);
	
	if (errcode == noErr) {
		
		while (!shellisactive ()) {
			
			if (flscriptrunning) {
				
				if (fldisableyield || inmainthread ())
					fl = langpartialeventloop (systemevents);
				else
					fl = langbackgroundtask (true); /*let main thread field events*/
				}
			else
				fl = shellpartialeventloop (systemevents);
			
			if (!fl)
				break;
			}
		
		NMRemove (pb);
		}
	
	disposehandle ((*pb).nmIcon);
	
	if ((*pb).nmStr != nil)
		DisposePtr ((Ptr) (*pb).nmStr);
	
	DisposePtr ((Ptr) pb);

	return (fl && (errcode == noErr));
#endif

#ifdef WIN95VERSION
	char s [256];
	short itemnumber;

	copyptocstring (bsmessage, s);

	releasethreadglobals ();

//#ifdef PIKE
//
//	/*7.0d8 PBS: name change to Radio UserLand*/
//
//	itemnumber = MessageBox (hwndMDIClient, s, "Radio UserLand", MB_OK | MB_ICONINFORMATION | MB_APPLMODAL);
//
//#else

/* 9.1b3 JES: APPNAME macro is defined in versions.h for both Radio and Frontier -- use instead of hard-coded string */
itemnumber = MessageBox (hwndMDIClient, s, APPNAME, MB_OK | MB_ICONINFORMATION | MB_APPLMODAL);

//#endif

	grabthreadglobals ();
	
	return (itemnumber == IDOK);
#endif
	} /*notifyuser*/