Beispiel #1
0
//-------------------------------------------------------------------------------
//
//	Shutdown
//
//	It's our responsibility to unregister any notifiers or memory we allocated
//	at startup.  So we iterate through the listener list, both removing
//	any notifiers and cleaning out memory.
//
//-------------------------------------------------------------------------------
static SPErr Shutdown (void)
{
	SPErr error = kSPNoError;
	
	Listener_t* thisList = gListenerList;
	
	while (thisList != NULL)
	{
		gEventID = thisList->eventID;
	
		error = sPSActionControl->RemoveNotify(gPlugInRef,
											   gEventID);

		gEventID = 0;
		thisList->eventID = 0;
		
		Listener_t* nextList = thisList->next;
		delete thisList;
		
		thisList = nextList;
	}		

	if (notifierOn)
			error = sPSActionControl->RemoveNotify(
				gPlugInRef,
				eventAll);				// Event we registered.

	// clean up after ourselves
	PIUSuitesRelease();

	return error;
}
Beispiel #2
0
//-------------------------------------------------------------------------------
//
//	AutoPluginMain / main
//
//	All calls to the plug-in module come through this routine.
//	It must be placed first in the resource.  To achieve this,
//	most development systems require this be the first routine
//	in the source.
//
//	The entrypoint will be "pascal void" for Macintosh,
//	"void" for Windows.
//
//-------------------------------------------------------------------------------
DLLExport SPAPI SPErr AutoPluginMain(const char* caller, const char* selector, void* message)
{

	SPErr error = kSPNoError;

	try {

	SPMessageData * basicMessage = (SPMessageData *) message;

	sSPBasic = basicMessage->basic;
	
	if (sSPBasic->IsEqual(caller, kSPInterfaceCaller))
	{
		if (sSPBasic->IsEqual(selector, kSPInterfaceAboutSelector))
		{
			DoAbout(basicMessage->self, AboutID);
		}
	}

	// Photoshop is calling
	if (sSPBasic->IsEqual((char*)caller, kPSPhotoshopCaller))
	{
		// the one and only message 
		if (sSPBasic->IsEqual((char*)selector, kPSDoIt))
		{
			//pop a dialog to show plug-in works
			PSActionsPlugInMessage * actionsMessage = (PSActionsPlugInMessage *) message;
			DoIt(actionsMessage);
		}
	}

	
	PIUSuitesRelease();

	}

	catch (...)
	{
		if (error == 0)
			error = kSPBadParameterError;
	}

	return error;
}
static SPErr Shutdown() {
	PIUSuitesRelease();
	
	return kSPNoError;
}
Beispiel #4
0
DLLExport MACPASCAL void PluginMain (const int16 selector,
                                     FormatRecordPtr formatParamBlock,
                                     intptr_t * data,
                                     int16 * result)
{

    try {

        //---------------------------------------------------------------------------
        //	(1) Check for about box request.
        //
        // 	The about box is a special request; the parameter block is not filled
        // 	out, none of the callbacks or standard data is available.  Instead,
        // 	the parameter block points to an AboutRecord, which is used
        // 	on Windows.
        //---------------------------------------------------------------------------
        if (selector == formatSelectorAbout)
        {
            AboutRecordPtr aboutRecord = reinterpret_cast<AboutRecordPtr>(formatParamBlock);
            sSPBasic = aboutRecord->sSPBasic;
            SPPluginRef sPluginRef = reinterpret_cast<SPPluginRef>(aboutRecord->plugInRef);
            DoAbout(sPluginRef, AboutID);
        }
        else
        {   // do the rest of the process as normal:

            sSPBasic = formatParamBlock->sSPBasic;


            //-----------------------------------------------------------------------
            //	Dispatch selector.
            //-----------------------------------------------------------------------
            switch (selector)
            {
            case formatSelectorReadStart:
                DoReadStart(formatParamBlock);
                break;
            case formatSelectorReadFinish:
                DoReadFinish(formatParamBlock);
                break;
            default:
                break;
            }


        } // about selector special

        // release any suites that we may have acquired
        if (selector == formatSelectorAbout ||
                selector == formatSelectorWriteFinish ||
                selector == formatSelectorReadFinish ||
                selector == formatSelectorOptionsFinish ||
                selector == formatSelectorEstimateFinish ||
                selector == formatSelectorFilterFile)
        {
            PIUSuitesRelease();
        }

    } // end try

    catch(...)
    {
        if (NULL != result)
        {
            *result = -1;
        }
    }

} // end PluginMain