示例#1
0
//===========================================================================
bool igApp::LoadPlugin( const wxString& pluginPath )
{
	bool success = false;

	do
	{
		if( plugin || pluginHandle != NULL )
			break;

		pluginHandle = LoadLibraryA( ( const char* )pluginPath.c_str() );
		if( pluginHandle == NULL )
			break;

		igPlugin::NewImageGeneratorPluginFunc func = ( igPlugin::NewImageGeneratorPluginFunc )GetProcAddress( pluginHandle, "NewImageGeneratorPlugin" );
		if( !func )
			break;

		plugin = func();
		if( !plugin )
			break;

		wxMenuBar* menuBar = frame->GetMenuBar();
		if( !plugin->Initialize( menuBar, frame ) )
			break;

		success = true;
	}
	while( false );

	if( !success )
		UnloadPlugin();

	return success;
}
示例#2
0
int main(int argc,char* argv[])
{
DWORD dwEntryPoint,dwSize;
void *Data;
hPLUGININSTANCE hInsts;
StartUpProc StartUp;

	printf("\nPrague module loader ver 0.1\n");
	if(argc<2)
	{
		printf(Usage);
		return 1;
	}

	hInsts = LoadPlugin(argv[1], &dwEntryPoint);
	if(hInsts)
	{
		printf("Load Plugin OK\n");
		StartUp=(StartUpProc)dwEntryPoint;
//		StartUp();
	}
	else
		printf("Load Plugin Failed\n");

	if(errOK==GetMetaData(argv[1], &Data,&dwSize))
		printf("GetMetaData OK\n");
	else
		printf("GetMetaData Failed\n");
	UnloadPlugin(hInsts);
	return 0;
}
void PluginManager::UnloadAllPlugins()
{
//    Manager::Get()->GetLogManager()->DebugLog("Count %d", m_Plugins.GetCount());

    while (m_Plugins.GetCount())
    {
        UnloadPlugin(m_Plugins[0]->plugin);
    }
    m_Plugins.Clear();
    LibLoader::Cleanup();
}
示例#4
0
//===========================================================================
/*virtual*/ int igApp::OnExit( void )
{
	if( plugin || pluginHandle != NULL )
		UnloadPlugin( true );

	DeleteImage();

	SaveConfiguration();

	return wxApp::OnExit();
}
bool mcuPluginManager::Close()
{
    if (m_pPlugin)
	{
        m_pPlugin->OnDetach();
        m_mcuName = _T("");
        m_family = _T("");
        m_DebugDriverManager.RegisterDriver(NULL);  // Just in case plugin didnt do it
        return UnloadPlugin();
    }
    return false;
}
extern "C" ASAPI ASErr PluginMain(char* caller, char* selector, void* message)
{
	AIErr error = kNoErr;

	// This is just an easy way of not having to cast message to ( SPMessageData* )
	// everytime we use IsEqual()
	sSPBasic = ( ( SPMessageData* )message)->basic;

	// standard caller/selectors
	
	// if these do anything other than restore globals, you may need to move them
	// into the aquire/releaseSuites block
	if ( sSPBasic->IsEqual( caller, kSPAccessCaller ) ) {
		if ( sSPBasic->IsEqual( selector, kSPAccessUnloadSelector ) )
			error = UnloadPlugin( (SPAccessMessage*) message );
	
		else if ( sSPBasic->IsEqual( selector, kSPAccessReloadSelector ) )
			error = ReloadPlugin( (SPAccessMessage*) message );
	} 
	
	else {
		// we need suites for the following routines, so acquire all of them now
		error = acquireSuites( ((SPInterfaceMessage*)message)->d.basic );
		if ( error )								
			goto error;							

		if ( sSPBasic->IsEqual( caller, kSPInterfaceCaller ) ) {
			if ( sSPBasic->IsEqual( selector, kSPInterfaceStartupSelector ) )
				error = StartupPlugin( (SPInterfaceMessage*) message );

//			else if ( sSPBasic->IsEqual( selector, kSPInterfaceAboutSelector ) )
//				error = AboutPlugin( (SPInterfaceMessage*) message );
				
			else if ( sSPBasic->IsEqual( selector, kSPInterfaceShutdownSelector ) )
				error = ShutdownPlugin( (SPInterfaceMessage*) message );
		
		} else  
			error = handlePluginCaller( caller, selector, message );

error:
		if ( (error) && (error != kSPSuiteNotFoundError) && (error != 1))
			report_error( (SPInterfaceMessage*) message, error );

		releaseSuites( ((SPInterfaceMessage*)message)->d.basic );
	}

	return error;

}
示例#7
0
LWRESULT Cx_PluginLoader::UnloadPluginAll(bool force_unload)
{
	LWRESULT res  = LWDP_OK;
	LWRESULT stat = LWDP_ERROR;
	for(uint32_ i=0; i<m_modules.size(); ++i)
	{
		Ix_Module* pModule = m_modules[i]->module;
		ASSERT_CHECK_RET(LWDP_MODULE_LOG, LWDP_POINTER_IS_NULL, pModule, "Cx_PluginLoader::UnloadPluginAll Get Ix_Module Pointer Error");

		stat = UnloadPlugin(pModule->GetModuleMODID(), force_unload);
		if(stat != LWDP_OK)
			res = stat;
	}
	
	return res;
}
        void Application::Terminate()
        {
            BOOST_ASSERT( m_IsInitialized == true );

            // Terminate the subsystems in the opposite order as they were registered.
            SubsystemList::reverse_iterator iter = m_Subsystems.rbegin();
            while ( iter != m_Subsystems.rend() )
            {
                SubsystemPtr subsystem = (*iter);
                subsystem->Terminate();

                ++iter;
            }

            m_Subsystems.clear();

            // Unload any previously loaded plug-ins
            PluginList plugins = m_Plugins;
            PluginList::iterator pluginIter = plugins.begin();
            while ( pluginIter != plugins.end() )
            {
                PluginPtr plugin = (*pluginIter);
                plugin->Terminate();

                UnloadPlugin( plugin );
                ++pluginIter;
            }

            plugins.clear();
            m_PluginsByName.clear();
            m_PluginsByFileName.clear();
            m_Plugins.clear();

            // Flush all the libraries.  At this point
            // there should be no residual pointers to objects
            // created in the library.
            m_DynamicLibSubsystem->Flush();

            m_IsInitialized = false;

            OnTerminated( EventArgs( *this ) );
        }
示例#9
0
文件: Main.c 项目: byterj/IRW_1.4
BOOL APIENTRY DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved)
{
    switch(fdwReason)
    {
        case DLL_PROCESS_ATTACH:
		{
			DisableThreadLibraryCalls(hDLLInst);
			DLLInst = hDLLInst;
		}break;
        case DLL_PROCESS_DETACH:
		{
			/* to make sure the dll wasn't simply loaded and InitPlugin() wasnt called */
			if(Inited == TRUE)
				UnloadPlugin();
		}break;
        case DLL_THREAD_ATTACH:		break;
        case DLL_THREAD_DETACH:		break;
    }
    return TRUE;
}
示例#10
0
int PPInstance::Stop( )
{
	m_eventStop.SetEvent( );
	::WaitForSingleObject( m_eventDownloadStopped.m_hObject, INFINITE ); 
    if ( m_p3dInstance )
    {
        P3D_instance_finish_ptr( m_p3dInstance );
        m_p3dInstance = NULL;
    }
    if ( m_p3dObject )
    {
        P3D_OBJECT_DECREF( m_p3dObject );
        m_p3dObject = NULL;
    }
    if ( m_pluginLoaded )
    {
        UnloadPlugin();
    }
	return 0;
}
示例#11
0
static
void LoadPlugin() {
	if ( !gLib ) {
		ef = fopen( "/tmp/plugin.log", "a" );
		DEB( ef, "-------------------------------\n" );
		fclose( ef );
		ef = fopen( "/tmp/plugin.log", "a" );
		setvbuf( ef, NULL, _IONBF, 0 );
		DEB( ef, "-> LoadPlugin\n" );
		
#ifdef __hpux
                gLib = shl_load("/tmp/plugin.so", BIND_IMMEDIATE, 0L);
                if (shl_findsym(&gLib, "/tmp/plugin.so", (short) TYPE_PROCEDURE, (void *) &gNP_GetMIMEDescription))
                   gNP_GetMIMEDescription = NULL;
                if (shl_findsym(&gLib, "/tmp/plugin.so", (short) TYPE_PROCEDURE, (void *) &gNP_Initialize))
                   gNP_Initialize = NULL;
                if (shl_findsym(&gLib, "/tmp/plugin.so", (short) TYPE_PROCEDURE, (void *) &gNP_Shutdown))
                   gNP_Shutdown = NULL;
                if (shl_findsym(&gLib, "/tmp/plugin.so", (short) TYPE_PROCEDURE, (void *) &gNP_GetValue))
                   gNP_GetValue = NULL;
#else
		gLib = dlopen( "/tmp/plugin.so", RTLD_NOW );
		DEB( ef, "gLib = %x\n", gLib );

		gNP_GetMIMEDescription = dlsym( gLib, "NP_GetMIMEDescription" );
		gNP_Initialize = dlsym( gLib, "NP_Initialize" );
		gNP_Shutdown = dlsym( gLib, "NP_Shutdown" );
		gNP_GetValue = dlsym( gLib, "NP_GetValue" );
#endif
		DEB( ef, "gNP_GetMIMEDescription = %x\n", NP_GetMIMEDescription );
		DEB( ef, "gNP_Initialize = %x\n", gNP_Initialize );
		DEB( ef, "gNP_Shutdown = %x\n", gNP_Shutdown );
		DEB( ef, "gNP_GetValue = %x\n", gNP_GetValue );
		
		if ( !gNP_GetMIMEDescription || !gNP_Initialize || !gNP_Initialize || !gNP_GetValue ) {
			DEB( ef, "<- LoadPlugin - will unload before\n" );
		 	UnloadPlugin();
		} else
				DEB( ef, "<- LoadPlugin\n" );
	}
}
示例#12
0
/* Handles message actions for this plug-in.
*/
extern "C" ASAPI ASErr PluginMain(char* caller, char* selector, void* message)
{
	ASErr error = kASNoError;
	if ( strcmp( caller, kSPAccessCaller ) == 0 ) {
		if ( strcmp( selector, kSPAccessUnloadSelector ) == 0 )
			error = UnloadPlugin( ( SPAccessMessage* )message );
		else if ( strcmp( selector, kSPAccessReloadSelector ) == 0 )
			error = ReloadPlugin( ( SPAccessMessage* )message );

	} 
	else if ( strcmp( caller, kSPInterfaceCaller ) == 0 ) {
		if ( strcmp( selector, kSPInterfaceStartupSelector ) == 0 )
			error = StartupPlugin( ( SPInterfaceMessage* )message );
		else if ( strcmp( selector, kSPInterfaceShutdownSelector ) == 0 )
			error = ShutdownPlugin( ( SPInterfaceMessage* )message );

	} 
	else if ( strcmp( caller, kCallerAIMenu ) == 0  ) {
		if ( strcmp( selector, kSelectorAIGoMenuItem ) == 0 ) 
			error = GoMenu( ( AIMenuMessage* )message );

	} 
	else if ( strcmp( caller, kCallerAIFilter ) == 0 ) {
		if ( strcmp( selector, kSelectorAIGetFilterParameters ) == 0 )
			error = GetFilterParameters( ( AIFilterMessage* )message );
		else if ( strcmp( selector, kSelectorAIGoFilter ) == 0 )
			error = GoFilter( ( AIFilterMessage* )message );
		
	} 
	else if ( strcmp( caller, kCallerAITool ) == 0  ) {
		if ( strcmp( selector, kSelectorAIToolMouseDown ) == 0 ) 
			error = ToolMouseDown( ( AIToolMessage* )message );

	} 
	else if ( strcmp( caller, kActionCaller ) == 0 ) {
		if ( strcmp( selector, kDoActionSelector ) == 0 )
			error = DoAction( ( DoActionMessage* )message );
	}
	return error;
}
示例#13
0
long Cx_PluginLoader::InitializePlugins()
{
    CLockCount locker(&m_loading);
    long count = 0;

    for (long i = 0; i < x3::GetSize(m_modules); i++)
    {
        if (m_modules[i]->inited)
        {
            continue;
        }
        if (!m_modules[i]->hdll) // delay-load
        {
            count++;
            m_modules[i]->inited = true;
            continue;
        }

        typedef bool (*FUNC_INIT)();
        FUNC_INIT pfn = (FUNC_INIT)GetProcAddress(
            m_modules[i]->hdll, "x3InitializePlugin");

        if (pfn && !(*pfn)())
        {
            GetModuleFileNameW(m_modules[i]->hdll, m_modules[i]->filename, MAX_PATH);
            X3LOG_WARNING2(L"@PluginManager:IDS_INITPLUGIN_FAIL", m_modules[i]->filename);
            VERIFY(UnloadPlugin(m_modules[i]->filename));
            i--;
        }
        else
        {
            count++;
            m_modules[i]->inited = true;
        }
    }

    SaveClsids();

    return count;
}
示例#14
0
/**
 *		DLL symbols
 */
BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{
	if(dwReason == DLL_PROCESS_ATTACH)
	{
		g_hDll				= hModule;
		g_bLoaded			= FALSE;
		g_hMainWnd			= NULL;
		NewMainProcData		= NULL;
		NewFrameProcData	= NULL;
		g_bMainReady		= FALSE;
		g_nLock				= 0;
		g_bInternalNew		= TRUE;
		g_hMenu				= 0;
		g_bRemoveMarker		= FALSE;
		DisableThreadLibraryCalls(g_hDll);
	}
	else if(dwReason == DLL_PROCESS_DETACH)
	{
		UnloadPlugin(NULL);
	}
	return TRUE;
}
示例#15
0
extern void __declspec(dllexport) Main(PLUGINDATA *pd)
{
	pd->dwSupport |= PDS_NOANSI;
	if(pd->dwSupport & PDS_GETSUPPORT)
		return;
	if(pd->bOldWindows)
	{
		pd->nUnload = UD_UNLOAD;
		return;
	}

	if(!g_bLoaded)
	{
		LoadPlugin(pd);
		if(!g_bLoaded)
		{
			pd->nUnload = UD_UNLOAD;
			return;
		}
	}
	if(g_bMainReady)
	{
		FreeMain();
	}
	else
	{
		InitMain();
		if(!pd->bOnStart)
		{
			g_bInternalNew = FALSE;
		}
	}
	pd->nUnload = (g_bMainReady)?
		(UD_NONUNLOAD_ACTIVE):
		(g_nLock?UD_NONUNLOAD_NONACTIVE:UD_UNLOAD);
	if(!g_nLock) UnloadPlugin(pd);
}
示例#16
0
ASErr Plugin::Message(char *caller, char *selector, void *message)
{
	ASErr error = kUnhandledMsgErr;

	/* Sweet Pea messages */

	if (sSPBasic->IsEqual(caller, kSPAccessCaller )) 
	{
		if (sSPBasic->IsEqual( selector, kSPAccessUnloadSelector))
			error = UnloadPlugin(static_cast<SPInterfaceMessage *>(message));
			
		else if (sSPBasic->IsEqual( selector, kSPAccessReloadSelector))
			error = ReloadPlugin(static_cast<SPInterfaceMessage *>(message));
	}
	else if (sSPBasic->IsEqual(caller, kSPInterfaceCaller)) 
	{	
		if (sSPBasic->IsEqual(selector, kSPInterfaceAboutSelector))
			error = About(static_cast<SPInterfaceMessage *>(message));

		else if (sSPBasic->IsEqual(selector, kSPInterfaceStartupSelector))
			error = StartupPlugin(static_cast<SPInterfaceMessage *>(message));

		else if (sSPBasic->IsEqual(selector, kSPInterfaceShutdownSelector))
			error = ShutdownPlugin(static_cast<SPInterfaceMessage *>(message));
	}
	else if (sSPBasic->IsEqual(caller, kSPCacheCaller)) 
	{	
		if (sSPBasic->IsEqual(selector, kSPPluginPurgeCachesSelector))
		{
			if (Purge())
				error = kSPPluginCachesFlushResponse;
			else
				error = kSPPluginCouldntFlushResponse;
		}
	}
	else if (sSPBasic->IsEqual( caller, kSPPropertiesCaller ))
	{
		if (sSPBasic->IsEqual( selector, kSPPropertiesAcquireSelector ))
		{
			error = AcquireProperty((SPPropertiesMessage *) message);
		}
		else if (sSPBasic->IsEqual( selector, kSPPropertiesReleaseSelector ))
		{
			error = ReleaseProperty((SPPropertiesMessage *) message);
		}
	}

	/* Some common AI messages */

	else if (sSPBasic->IsEqual(caller, kCallerAINotify)) 
	{
		AppContext appContext(((SPInterfaceMessage *)message)->d.self);

		// Ideally we would rely upon the caller to envelop our Notify method.
		// But since we won't work right if he doesn't, do this ourselves

		AINotifierMessage *msg = (AINotifierMessage *)message;

		if (sSPBasic->IsEqual(msg->type, kAIApplicationStartedNotifier))
			error = PostStartupPlugin();

		if (!error || error == kUnhandledMsgErr)
		{
			if (sSPBasic->IsEqual( selector, kSelectorAINotify ))
				error = Notify(msg);
		}
	}
	else if (sSPBasic->IsEqual(caller, kCallerAIMenu))
	{
		if (sSPBasic->IsEqual( selector, kSelectorAIGoMenuItem ))
		{
			error = GoMenuItem((AIMenuMessage *)message);
		}
		else if (sSPBasic->IsEqual( selector, kSelectorAIUpdateMenuItem ))
		{
			error = UpdateMenuItem((AIMenuMessage *)message);
		}
	}
	else if (sSPBasic->IsEqual(caller, kCallerAIFilter))
	{
		if (sSPBasic->IsEqual( selector, kSelectorAIGetFilterParameters ))
		{
			error = GetFilterParameters((AIFilterMessage *)message);
		}
		else if (sSPBasic->IsEqual( selector, kSelectorAIGoFilter ))
		{
			error = GoFilter((AIFilterMessage *)message);
		}
	}
	else if (sSPBasic->IsEqual(caller, kCallerAIPluginGroup))
	{
		if (sSPBasic->IsEqual( selector, kSelectorAINotifyEdits ))
		{
			error = PluginGroupNotify((AIPluginGroupMessage *)message);
		}
		else if (sSPBasic->IsEqual( selector, kSelectorAIUpdateArt ))
		{
			error = PluginGroupUpdate((AIPluginGroupMessage *)message);
		}
	}
	else if (sSPBasic->IsEqual(caller, kCallerAIFileFormat))
	{
		if (sSPBasic->IsEqual( selector, kSelectorAIGetFileFormatParameters ))
		{
			error = GetFileFormatParameters((AIFileFormatMessage *)message);
		}
		else if (sSPBasic->IsEqual( selector, kSelectorAIGoFileFormat ))
		{
			error = GoFileFormat((AIFileFormatMessage *)message);
		}
		else if (sSPBasic->IsEqual( selector, kSelectorAICheckFileFormat ))
		{
			error = CheckFileFormat((AIFileFormatMessage *)message);
		}
	}
	else if (sSPBasic->IsEqual(caller, kCallerAITool))
	{
		if (sSPBasic->IsEqual( selector, kSelectorAIEditToolOptions ))
		{
			error = EditTool((AIToolMessage *)message);
		}
		else if (sSPBasic->IsEqual( selector, kSelectorAITrackToolCursor ))
		{
			error = TrackToolCursor((AIToolMessage *)message);
		}
		else if (sSPBasic->IsEqual( selector, kSelectorAIToolMouseDown ))
		{
			error = ToolMouseDown((AIToolMessage *)message);
		}
		else if (sSPBasic->IsEqual( selector, kSelectorAIToolMouseDrag ))
		{
			error = ToolMouseDrag((AIToolMessage *)message);
		}
		else if (sSPBasic->IsEqual( selector, kSelectorAIToolMouseUp ))
		{
			error = ToolMouseUp((AIToolMessage *)message);
		}
		else if (sSPBasic->IsEqual( selector, kSelectorAISelectTool ))
		{
			error = SelectTool((AIToolMessage *)message);
		}
		else if (sSPBasic->IsEqual( selector, kSelectorAIDeselectTool ))
		{
			error = DeselectTool((AIToolMessage *)message);
		}
		else if (sSPBasic->IsEqual( selector, kSelectorAIReselectTool ))
		{
			error = ReselectTool((AIToolMessage *)message);
		}
	} 
	else if (sSPBasic->IsEqual(caller, kCallerAILiveEffect )) 
	{
		if (sSPBasic->IsEqual( selector, kSelectorAIEditLiveEffectParameters ))
		{
			error = EditLiveEffectParameters((AILiveEffectEditParamMessage *)message);
		}
		else if (sSPBasic->IsEqual( selector, kSelectorAIGoLiveEffect ))
		{
			error = GoLiveEffect((AILiveEffectGoMessage *)message);
		}
		else if (sSPBasic->IsEqual( selector, kSelectorAILiveEffectInterpolate ))
		{
			error = LiveEffectInterpolate((AILiveEffectInterpParamMessage *)message);
		}
		else if (sSPBasic->IsEqual( selector, kSelectorAILiveEffectInputType ))
		{
			error = LiveEffectGetInputType((AILiveEffectInputTypeMessage *)message);
		}

	}
	else if (sSPBasic->IsEqual(caller, kCallerAITimer )) 
	{
		if (sSPBasic->IsEqual( selector, kSelectorAIGoTimer ))
		{
			error = Timer((AITimerMessage *)message);
		}
	}
	// We should probably handle some ADM messages too, but I don't know
	// which ones right now...

	return error;
}
示例#17
0
static INT_PTR CALLBACK AccFormDlgProc(HWND hwndDlg,UINT message, WPARAM wParam, LPARAM lParam)
{
	switch( message ) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		{
			PROTOCOLDESCRIPTOR** proto;
			int protoCount, i, cnt = 0;
			Proto_EnumProtocols(( WPARAM )&protoCount, ( LPARAM )&proto );
			for ( i=0; i < protoCount; i++ ) {
				PROTOCOLDESCRIPTOR* pd = proto[i];
				if ( pd->type == PROTOTYPE_PROTOCOL && pd->cbSize == sizeof( *pd )) {
					SendDlgItemMessageA( hwndDlg, IDC_PROTOTYPECOMBO, CB_ADDSTRING, 0, (LPARAM)proto[i]->szName );
					++cnt;
				}
			}
			SendDlgItemMessage( hwndDlg, IDC_PROTOTYPECOMBO, CB_SETCURSEL, 0, 0 );
			EnableWindow( GetDlgItem( hwndDlg, IDOK ), cnt != 0 );

			SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam );
			AccFormDlgParam* param = ( AccFormDlgParam* )lParam;

			if ( param->action == PRAC_ADDED ) // new account
				SetWindowText( hwndDlg, TranslateT( "Create new account" ));
			else {
				TCHAR str[200];
				if ( param->action == PRAC_CHANGED ) { // update
					EnableWindow( GetDlgItem( hwndDlg, IDC_PROTOTYPECOMBO ), FALSE );
					mir_sntprintf( str, SIZEOF(str), _T("%s: %s"), TranslateT( "Editing account" ), param->pa->tszAccountName );
				}
				else mir_sntprintf( str, SIZEOF(str), _T("%s: %s"), TranslateT( "Upgrading account" ), param->pa->tszAccountName );

				SetWindowText( hwndDlg, str );
				SetDlgItemText( hwndDlg, IDC_ACCNAME, param->pa->tszAccountName );
				SetDlgItemTextA( hwndDlg, IDC_ACCINTERNALNAME, param->pa->szModuleName );
				SendDlgItemMessageA( hwndDlg, IDC_PROTOTYPECOMBO, CB_SELECTSTRING, -1, (LPARAM)param->pa->szProtoName );

				EnableWindow( GetDlgItem( hwndDlg, IDC_ACCINTERNALNAME ), FALSE );
			}
			SendDlgItemMessage( hwndDlg, IDC_ACCINTERNALNAME, EM_LIMITTEXT, 40, 0 );
		}
		return TRUE;

	case WM_COMMAND:
		switch( LOWORD(wParam)) {
		case IDOK:
			{
				AccFormDlgParam* param = ( AccFormDlgParam* )GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
				PROTOACCOUNT* pa = param->pa;

				if ( param->action == PRAC_ADDED ) {
					char buf[200];
					GetDlgItemTextA( hwndDlg, IDC_ACCINTERNALNAME, buf, SIZEOF( buf ));
					rtrim( buf );
					if ( buf[0] ) {
						for (int i = 0; i < accounts.getCount(); ++i)
							if (_stricmp(buf, accounts[i]->szModuleName) == 0)
								return FALSE;
				}	}

				switch( param->action ) {
				case PRAC_UPGRADED:
					{
						int idx;
						BOOL oldProto = pa->bOldProto;
						TCHAR szPlugin[MAX_PATH];
						mir_sntprintf(szPlugin, SIZEOF(szPlugin), _T("%s.dll"), StrConvT(pa->szProtoName));
						idx = accounts.getIndex(pa);
						UnloadAccount(pa, false, false);
						accounts.remove(idx);
						if (oldProto && UnloadPlugin(szPlugin, SIZEOF(szPlugin))) 
						{
							TCHAR szNewName[MAX_PATH];
							mir_sntprintf(szNewName, SIZEOF(szNewName), _T("%s~"), szPlugin);
							MoveFile(szPlugin, szNewName);
						}
					}
					// fall through

				case PRAC_ADDED:
					pa = (PROTOACCOUNT*)mir_calloc( sizeof( PROTOACCOUNT ));
					pa->cbSize = sizeof( PROTOACCOUNT );
					pa->bIsEnabled = TRUE;
                    pa->bIsVisible = TRUE;
                    
					pa->iOrder = accounts.getCount();
					pa->type = PROTOTYPE_PROTOCOL;
					break;
				}
				{
					TCHAR buf[256];
					GetDlgItemText( hwndDlg, IDC_ACCNAME, buf, SIZEOF( buf ));
					mir_free(pa->tszAccountName);
					pa->tszAccountName = mir_tstrdup( buf );
				}
				if ( param->action == PRAC_ADDED || param->action == PRAC_UPGRADED ) 
                {
					char buf[200];
					GetDlgItemTextA( hwndDlg, IDC_PROTOTYPECOMBO, buf, SIZEOF( buf ));
					pa->szProtoName = mir_strdup( buf );
					GetDlgItemTextA( hwndDlg, IDC_ACCINTERNALNAME, buf, SIZEOF( buf ));
					rtrim( buf );
					if ( buf[0] == 0 ) {
						int count = 1;
						for( ;; ) {
							DBVARIANT dbv;
							mir_snprintf( buf, SIZEOF(buf), "%s_%d", pa->szProtoName, count++ );
							if ( DBGetContactSettingString( NULL, buf, "AM_BaseProto", &dbv ))
								break;
							DBFreeVariant( &dbv );
					}	}
					pa->szModuleName = mir_strdup( buf );

					if ( !pa->tszAccountName[0] ) {
						mir_free(pa->tszAccountName);
						pa->tszAccountName = mir_a2t(buf);
					}

					DBWriteContactSettingString( NULL, pa->szModuleName, "AM_BaseProto", pa->szProtoName );
					accounts.insert( pa );

					if ( ActivateAccount( pa )) {
						pa->ppro->OnEvent( EV_PROTO_ONLOAD, 0, 0 );
						if (!DBGetContactSettingByte(NULL, "CList", "MoveProtoMenus", FALSE))
							pa->ppro->OnEvent( EV_PROTO_ONMENU, 0, 0 );
					}
					else pa->type = PROTOTYPE_DISPROTO;
				}

				WriteDbAccounts();
				NotifyEventHooks( hAccListChanged, param->action, ( LPARAM )pa );

				SendMessage( GetParent(hwndDlg), WM_MY_REFRESH, 0, 0 );
			}

			EndDialog( hwndDlg, TRUE );
			break;

		case IDCANCEL:
			EndDialog( hwndDlg, FALSE );
			break;
		}
	}

	return FALSE;
}
示例#18
0
bool CPlugin::Load(const char * FileName)
{
    // Already loaded, so unload first.
    if (m_hDll != NULL)
    {
        UnloadPlugin();
    }

    // Try to load the plugin DLL
    //Try to load the DLL library
    if (bHaveDebugger())
    {
        m_hDll = LoadLibrary(FileName);
    }
    else
    {
        UINT LastErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
        m_hDll = LoadLibrary(FileName);
        SetErrorMode(LastErrorMode);
    }

    if (m_hDll == NULL)
    {
        return false;
    }

    // Get DLL information
    void(__cdecl *GetDllInfo) (PLUGIN_INFO * PluginInfo);
    LoadFunction(GetDllInfo);
    if (GetDllInfo == NULL) { return false; }

    GetDllInfo(&m_PluginInfo);
    if (!ValidPluginVersion(m_PluginInfo)) { return false; }
    if (m_PluginInfo.Type != type()) { return false; }

    CloseDLL = (void(__cdecl *)(void)) GetProcAddress((HMODULE)m_hDll, "CloseDLL");
    RomOpen = (void(__cdecl *)(void)) GetProcAddress((HMODULE)m_hDll, "RomOpen");
    RomClosed = (void(__cdecl *)(void)) GetProcAddress((HMODULE)m_hDll, "RomClosed");
    PluginOpened = (void(__cdecl *)(void)) GetProcAddress((HMODULE)m_hDll, "PluginLoaded");
    DllConfig = (void(__cdecl *)(void *)) GetProcAddress((HMODULE)m_hDll, "DllConfig");
    DllAbout = (void(__cdecl *)(void *)) GetProcAddress((HMODULE)m_hDll, "DllAbout");

    SetSettingInfo3 = (void(__cdecl *)(PLUGIN_SETTINGS3 *))GetProcAddress((HMODULE)m_hDll, "SetSettingInfo3");
    if (SetSettingInfo3)
    {
        PLUGIN_SETTINGS3 info;
        info.FlushSettings = (void(*)(void * handle))CSettings::FlushSettings;
        SetSettingInfo3(&info);
    }

    SetSettingInfo2 = (void(__cdecl *)(PLUGIN_SETTINGS2 *))GetProcAddress((HMODULE)m_hDll, "SetSettingInfo2");
    if (SetSettingInfo2)
    {
        PLUGIN_SETTINGS2 info;
        info.FindSystemSettingId = (uint32_t(*)(void * handle, const char *))CSettings::FindSetting;
        SetSettingInfo2(&info);
    }

    SetSettingInfo = (void(__cdecl *)(PLUGIN_SETTINGS *))GetProcAddress((HMODULE)m_hDll, "SetSettingInfo");
    if (SetSettingInfo)
    {
        PLUGIN_SETTINGS info;
        info.dwSize = sizeof(PLUGIN_SETTINGS);
        info.DefaultStartRange = GetDefaultSettingStartRange();
        info.SettingStartRange = GetSettingStartRange();
        info.MaximumSettings = MaxPluginSetting;
        info.NoDefault = Default_None;
        info.DefaultLocation = g_Settings->LoadDword(Setting_UseFromRegistry) ? SettingType_Registry : SettingType_CfgFile;
        info.handle = g_Settings;
        info.RegisterSetting = (void(*)(void *, int, int, SettingDataType, SettingType, const char *, const char *, uint32_t))&CSettings::RegisterSetting;
        info.GetSetting = (uint32_t(*)(void *, int))&CSettings::GetSetting;
        info.GetSettingSz = (const char * (*)(void *, int, char *, int))&CSettings::GetSettingSz;
        info.SetSetting = (void(*)(void *, int, uint32_t))&CSettings::SetSetting;
        info.SetSettingSz = (void(*)(void *, int, const char *))&CSettings::SetSettingSz;
        info.UseUnregisteredSetting = NULL;

        SetSettingInfo(&info);
    }

    if (RomClosed == NULL)
        return false;

    if (!LoadFunctions())
    {
        return false;
    }
    WriteTrace(PluginTraceType(), TraceDebug, "Functions loaded");

    if (PluginOpened)
    {
        WriteTrace(PluginTraceType(), TraceDebug, "Before Plugin Opened");
        PluginOpened();
        WriteTrace(PluginTraceType(), TraceDebug, "After Plugin Opened");
    }
    return true;
}
示例#19
0
extern void __declspec(dllexport) Open(PLUGINDATA *pd)
{
	INT_PTR res;
	DWORD_PTR* param;
	EDITINFO ei;
	BOOL bInsert = FALSE;
	pd->dwSupport |= PDS_NOANSI|PDS_NOAUTOLOAD;
	if(pd->dwSupport & PDS_GETSUPPORT)
		return;
	if(pd->bOldWindows)
	{
		pd->nUnload = UD_UNLOAD;
		return;
	}
	if(!g_bLoaded)
	{
		LoadPlugin(pd);
		if(!g_bLoaded)
		{
			pd->nUnload = UD_UNLOAD;
			return;
		}
	}
	g_nLock++;
	ei.hWndEdit = NULL;
	if(SendMessageW(g_hMainWnd,AKD_GETEDITINFO,0,(LPARAM)&ei))
	{
		if(ei.hWndEdit && ei.wszFile)
			bInsert = !ei.bReadOnly;
	}
	param = (DWORD_PTR*)pd->lParam;
	if(	param
		&& (param[0]==3*sizeof(DWORD_PTR))
		&& (param[1]==OPEN_FUNCTION_OPEN
			|| param[1]==OPEN_FUNCTION_EDIT
			|| param[1]==OPEN_FUNCTION_INSERT)
		&& param[2])
	{
		LPCWSTR p = (LPCWSTR)param[2];
		res = (param[1]==OPEN_FUNCTION_OPEN)
					?(IDOK)
					:((param[1]==OPEN_FUNCTION_EDIT)
							?IDC_EDIT:
							IDC_INSERT);
		if(p[0])
		{
			lstrcpyW(g_szTemplate,g_szAkelPath);
			lstrcatW(g_szTemplate,TEMPLATES_PATH);
			lstrcatW(g_szTemplate,L"\\");
			lstrcatW(g_szTemplate,p);
		}
		else g_szTemplate[0] = 0;
		if(res==IDC_EDIT)
		{
			HANDLE h = CreateFileW(g_szTemplate,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
			if(h == INVALID_HANDLE_VALUE)
			{
				res = IDCANCEL;
			}
			else
			{
				CloseHandle(h);
			}
		}
		else if((res == IDC_INSERT) && (!bInsert))
		{
			res = IDCANCEL;
		}
	}
	else
	{
		res = DialogBoxParamW(g_hDll,MAKEINTRESOURCEW(IDD_TEMPLATE),g_hMainWnd,(DLGPROC)TemplateDlg,(LPARAM)DCP_ALLOWEDIT|(bInsert?DCP_ALLOWINSERT:0));
	}
	if(IDOK == res || IDC_EDIT == res || IDC_INSERT == res)
	{
		if(g_bMainReady)
		{
			g_bInternalNew = TRUE;
		}
		if(res == IDC_EDIT)
		{
			EditTemplate(FALSE);
		}
		else if(res == IDOK)
		{
			ei.hWndEdit = NULL;
			if(SendMessageW(g_hMainWnd,AKD_GETEDITINFO,0,(LPARAM)&ei))
			{
				if(!ei.hWndEdit || ei.bModified || ei.wszFile[0])
				{
					if(SendMessageW(g_hMainWnd,WM_COMMAND,MAKEWPARAM(IDM_FILE_NEW,0),TRUE))
					{
						SendMessageW(g_hMainWnd,AKD_GETEDITINFO,0,(LPARAM)&ei);
					}
				}
			}
			else if(g_nMDI == WMD_MDI)
			{
				if(SendMessageW(g_hMainWnd,WM_COMMAND,MAKEWPARAM(IDM_FILE_NEW,0),TRUE))
				{
					SendMessageW(g_hMainWnd,AKD_GETEDITINFO,0,(LPARAM)&ei);
				}
			}
			if(ei.hWndEdit && !((g_nMDI == WMD_SDI)&&(ei.bModified)))
			{
				OpenTemplate(ei.hWndEdit,FALSE);
			}
		}
		else if(res == IDC_INSERT)
		{
			if(SendMessageW(g_hMainWnd,AKD_GETEDITINFO,0,(LPARAM)&ei))
			{
				if(ei.hWndEdit)
				{
					OpenTemplate(ei.hWndEdit,TRUE);
				}
			}
		}
		if(g_bMainReady)
		{
			g_bInternalNew = FALSE;
		}
	}
	g_nLock--;
	pd->nUnload = (g_nLock)?UD_NONUNLOAD_NONACTIVE:UD_UNLOAD;
	if(!g_nLock) UnloadPlugin(pd);
}
示例#20
0
CAudioPlugin::~CAudioPlugin()
{
    Close();
    UnloadPlugin();
}
示例#21
0
CDSMPlugin::~CDSMPlugin()
{
	// TODO: Log events
	if (IsLoaded())
		UnloadPlugin();
}
示例#22
0
CRSP_Plugin::~CRSP_Plugin()
{
    Close();
    UnloadPlugin();
}
示例#23
0
CPlugin::~CPlugin()
{
    UnloadPlugin();
}
示例#24
0
CControl_Plugin::~CControl_Plugin()
{
    Close();
    UnloadPlugin();
}
示例#25
0
bool PluginManager::UninstallPlugin(cbPlugin* plugin, bool removeFiles)
{
    if (!plugin)
        return false;

    wxString title;
    wxString pluginFilename;
    wxString resourceFilename;
    wxString settingsOnFilename;
    wxString settingsOffFilename;
    wxArrayString extrafiles;

    // find the plugin element
    for (size_t i = 0; i < m_Plugins.GetCount(); ++i)
    {
        PluginElement* elem = m_Plugins[i];
        if (elem && elem->plugin == plugin)
        {
            // got it
            title = elem->info.title;
            pluginFilename = elem->fileName;
            // now get the resource name
            wxFileName fname(pluginFilename);
            resourceFilename = fname.GetName() + _T(".zip");
            settingsOnFilename = fname.GetName() + _T(".png");
            settingsOffFilename = fname.GetName() + _T("-off.png");
            if (!platform::windows && resourceFilename.StartsWith(_T("lib")))
                resourceFilename.Remove(0, 3);
            if (!platform::windows && settingsOnFilename.StartsWith(_T("lib")))
                settingsOnFilename.Remove(0, 3);
            if (!platform::windows && settingsOffFilename.StartsWith(_T("lib")))
                settingsOffFilename.Remove(0, 3);
            resourceFilename = ConfigManager::LocateDataFile(resourceFilename, sdDataGlobal | sdDataUser);
            settingsOnFilename = ConfigManager::LocateDataFile(_T("images/settings/") + settingsOnFilename, sdDataGlobal | sdDataUser);
            settingsOffFilename = ConfigManager::LocateDataFile(_T("images/settings/") + settingsOffFilename, sdDataGlobal | sdDataUser);

            ReadExtraFilesFromManifestFile(resourceFilename, extrafiles);
            for (size_t n = 0; n < extrafiles.GetCount(); ++n)
            {
                extrafiles[n] = ConfigManager::LocateDataFile(extrafiles[n], sdDataGlobal | sdDataUser);
            }
            break;
        }
    }

    if (wxFileExists(pluginFilename) && !wxFile::Access(pluginFilename, wxFile::write))
    {
        // no write-access; abort
        cbMessageBox(_("You don't have the needed privileges to uninstall this plugin.\n"
                        "Ask your administrator to uninstall this plugin for you..."),
                        _("Warning"), wxICON_WARNING);
        return false;
    }

//    Manager::Get()->GetLogManager()->DebugLog(F(_T("UninstallPlugin:")));
//    Manager::Get()->GetLogManager()->DebugLog(F(_T("Plugin filename: ") + pluginFilename));
//    Manager::Get()->GetLogManager()->DebugLog(F(_T("Plugin resources: ") + resourceFilename));

    wxProgressDialog pd(wxString::Format(_("Uninstalling %s"), title.c_str()),
                        _T("A description wide enough for the dialog ;)"), 3);

    pd.Update(1, _("Detaching plugin"));
    DetachPlugin(plugin);
//    Manager::Get()->GetLogManager()->DebugLog(F(_T("Plugin released")));

    pd.Update(2, _("Updating menus and toolbars"));
    CodeBlocksEvent event(cbEVT_PLUGIN_UNINSTALLED);
    event.SetPlugin(plugin);
    Manager::Get()->ProcessEvent(event);
//    Manager::Get()->GetLogManager()->DebugLog(F(_T("Menus updated")));

    pd.Update(3, _("Unloading plugin"));
    UnloadPlugin(plugin);
//    Manager::Get()->GetLogManager()->DebugLog(F(_T("Plugin unloaded")));

    if (!removeFiles)
        return true;

    // under linux, if the progress dialog is still visible and updated
    // causes a crash because it re-enters gtk_main_iteration() calling
    // eventually OnUpdateUI() in the config dialog, which in turn references
    // an invalid plugin...
//    pd.Update(4, _("Removing files"));

    if (!pluginFilename.IsEmpty())
    {
        if (wxRemoveFile(pluginFilename))
        {
//            Manager::Get()->GetLogManager()->DebugLog(F(_T("Plugin file removed")));
            if (!resourceFilename.IsEmpty())
            {
                if (!wxRemoveFile(resourceFilename))
                    Manager::Get()->GetLogManager()->LogWarning(_T("Failed to remove plugin resources: ") + resourceFilename);
            }
            if (!settingsOnFilename.IsEmpty() && wxFileExists(settingsOnFilename))
            {
                if (!wxRemoveFile(settingsOnFilename))
                    Manager::Get()->GetLogManager()->LogWarning(_T("Failed to remove icon for \"Settings\" dialog: ") + settingsOnFilename);
            }
            if (!settingsOffFilename.IsEmpty() && wxFileExists(settingsOffFilename))
            {
                if (!wxRemoveFile(settingsOffFilename))
                    Manager::Get()->GetLogManager()->LogWarning(_T("Failed to remove icon for \"Settings\" dialog: ") + settingsOffFilename);
            }
            for (size_t i = 0; i < extrafiles.GetCount(); ++i)
            {
                if (!extrafiles[i].IsEmpty() && wxFileExists(extrafiles[i]))
                {
                    if (!wxRemoveFile(extrafiles[i]))
                        Manager::Get()->GetLogManager()->LogWarning(_T("Failed to remove extra file: ") + extrafiles[i]);
                }
            }
            return true;
        }
        else
        {
            Manager::Get()->GetLogManager()->LogWarning(_T("Failed to remove plugin file: ") + pluginFilename);
            cbMessageBox(_("Plugin could not be completely uninstalled because its files could not be removed.\n\n"
                            "This can happen if the plugin's file is in-use like, for "
                            "example, when the same plugin file provides more than one "
                            "plugin.\n"
                            "In this case either uninstall all other plugins "
                            "which are provided by the same file, or remove it yourself "
                            "(manually) when you shut down Code::Blocks.\n"
                            "The files that could not be deleted are:\n\n") +
                            pluginFilename + _T('\n') +
                            resourceFilename + _T('\n') +
                            settingsOnFilename + _T('\n') +
                            settingsOffFilename,
                            _("Warning"), wxICON_WARNING);
            return false;
        }
    }
    return false;
}
示例#26
0
bool CPlugin::Load(const char * FileName)
{
    // Already loaded, so unload first.
    if (m_LibHandle != NULL)
    {
        UnloadPlugin();
    }

    // Try to load the plugin DLL
    //Try to load the DLL library
    m_LibHandle = pjutil::DynLibOpen(FileName, bHaveDebugger());
    if (m_LibHandle == NULL)
    {
        return false;
    }

    // Get DLL information
    void(CALL *GetDllInfo) (PLUGIN_INFO * PluginInfo);
    LoadFunction(GetDllInfo);
    if (GetDllInfo == NULL) { return false; }

    GetDllInfo(&m_PluginInfo);
    if (!ValidPluginVersion(m_PluginInfo)) { return false; }
    if (m_PluginInfo.Type != type()) { return false; }

    LoadFunction(CloseDLL);
    LoadFunction(RomOpen);
    LoadFunction(RomClosed);
    _LoadFunction("PluginLoaded", PluginOpened);
    LoadFunction(DllConfig);
    LoadFunction(DllAbout);

    LoadFunction(SetSettingInfo3);
    if (SetSettingInfo3)
    {
        PLUGIN_SETTINGS3 info;
        info.FlushSettings = (void(*)(void * handle))CSettings::FlushSettings;
        SetSettingInfo3(&info);
    }

    LoadFunction(SetSettingInfo2);
    if (SetSettingInfo2)
    {
        PLUGIN_SETTINGS2 info;
        info.FindSystemSettingId = (uint32_t(*)(void * handle, const char *))CSettings::FindSetting;
        SetSettingInfo2(&info);
    }

    LoadFunction(SetSettingInfo);
    if (SetSettingInfo)
    {
        PLUGIN_SETTINGS info;
        info.dwSize = sizeof(PLUGIN_SETTINGS);
        info.DefaultStartRange = GetDefaultSettingStartRange();
        info.SettingStartRange = GetSettingStartRange();
        info.MaximumSettings = MaxPluginSetting;
        info.NoDefault = Default_None;
        info.DefaultLocation = g_Settings->LoadDword(Setting_UseFromRegistry) ? SettingType_Registry : SettingType_CfgFile;
        info.handle = g_Settings;
        info.RegisterSetting = (void(*)(void *, int, int, SettingDataType, SettingType, const char *, const char *, uint32_t))&CSettings::RegisterSetting;
        info.GetSetting = (uint32_t(*)(void *, int))&CSettings::GetSetting;
        info.GetSettingSz = (const char * (*)(void *, int, char *, int))&CSettings::GetSettingSz;
        info.SetSetting = (void(*)(void *, int, uint32_t))&CSettings::SetSetting;
        info.SetSettingSz = (void(*)(void *, int, const char *))&CSettings::SetSettingSz;
        info.UseUnregisteredSetting = NULL;

        SetSettingInfo(&info);
    }

    if (RomClosed == NULL)
    {
        return false;
    }

    if (!LoadFunctions())
    {
        return false;
    }
    WriteTrace(PluginTraceType(), TraceDebug, "Functions loaded");

    if (PluginOpened)
    {
        WriteTrace(PluginTraceType(), TraceDebug, "Before Plugin Opened");
        PluginOpened();
        WriteTrace(PluginTraceType(), TraceDebug, "After Plugin Opened");
    }
    return true;
}
示例#27
0
ASErr Plugin::Message(char *caller, char *selector, void *message)
{
	ASErr error = kUnhandledMsgErr;

	//sAIUser->MessageAlert(ai::UnicodeString(caller));
	
	// Acquire any missing optional suites.
	AcquireOptionalSuites();

	/* Sweet Pea messages */

	

	if (strcmp(caller, kSPAccessCaller ) == 0)
	{
		if (strcmp( selector, kSPAccessUnloadSelector) == 0)
			error = UnloadPlugin((SPInterfaceMessage *)message);

		else if (strcmp( selector, kSPAccessReloadSelector) == 0)
			error = ReloadPlugin((SPInterfaceMessage *)message);
	}
	else if (strcmp(caller, kSPInterfaceCaller) == 0)
	{
		if (strcmp(selector, kSPInterfaceAboutSelector) == 0)
			error = kNoErr;

		else if (strcmp(selector, kSPInterfaceStartupSelector) == 0)
			error = kNoErr;
	}
	else if (strcmp(caller, kSPCacheCaller) == 0)
	{
		if (strcmp(selector, kSPPluginPurgeCachesSelector) == 0)
		{
			if (Purge())
				error = kSPPluginCachesFlushResponse;
			else
				error = kSPPluginCouldntFlushResponse;
		}
	}
	else if (strcmp( caller, kSPPropertiesCaller ) == 0)
	{
		if (strcmp( selector, kSPPropertiesAcquireSelector ) == 0)
		{
			error = AcquireProperty((SPPropertiesMessage *) message);
		}
		else if (strcmp( selector, kSPPropertiesReleaseSelector ) == 0)
		{
			error = ReleaseProperty((SPPropertiesMessage *) message);
		}
	}

	/* Some common AI messages */

	else if (strcmp(caller, kCallerAINotify) == 0)
	{
		AppContext appContext(((SPInterfaceMessage *)message)->d.self);

		// Ideally we would rely upon the caller to envelop our Notify method.
		// But since we won't work right if he doesn't, do this ourselves

		AINotifierMessage *msg = (AINotifierMessage *)message;

		if (strcmp(msg->type, kAIApplicationStartedNotifier) == 0)
			error = PostStartupPlugin();

		if (!error || error == kUnhandledMsgErr)
		{
			if (strcmp( selector, kSelectorAINotify ) == 0)
				error = Notify(msg);
		}
	}
	else if (strcmp(caller, kActionCaller) == 0)
	{
		if (strcmp( selector, kDoActionSelector ) == 0)
		{
			/*
			char *my_argv[] = { "program name", "arg1", "arg2", NULL };
			int my_argc = sizeof(my_argv) / sizeof(char*) - 1;

			QApplication a(my_argc, my_argv);
			MyQTUI w;
			w.show();
			a.exec();*/
			error = GoAction((DoActionMessage *)message);
		}
	}
	else if (strcmp(caller, kCallerAIMenu) == 0)
	{
		if (strcmp( selector, kSelectorAIGoMenuItem ) == 0)
		{
			//sAIUser->MessageAlert(ai::UnicodeString("GoMenuItem"));
			error = GoMenuItem((AIMenuMessage *)message);
		}
		else if (strcmp( selector, kSelectorAIUpdateMenuItem ) == 0)
		{
			//sAIUser->MessageAlert(ai::UnicodeString("UpdateMenuItem"));
			error = UpdateMenuItem((AIMenuMessage *)message);
		}
	}
	else if (strcmp(caller, kCallerAIFilter) == 0)
	{
		if (strcmp( selector, kSelectorAIGetFilterParameters ) == 0)
		{
			error = GetFilterParameters((AIFilterMessage *)message);
		}
		else if (strcmp( selector, kSelectorAIGoFilter ) == 0)
		{
			error = GoFilter((AIFilterMessage *)message);
		}
	}
	else if (strcmp(caller, kCallerAIPluginGroup) == 0)
	{
		if (strcmp( selector, kSelectorAINotifyEdits ) == 0)
		{
			error = PluginGroupNotify((AIPluginGroupMessage *)message);
		}
		else if (strcmp( selector, kSelectorAIUpdateArt ) == 0)
		{
			error = PluginGroupUpdate((AIPluginGroupMessage *)message);
		}
	}
	else if (strcmp(caller, kCallerAIFileFormat) == 0)
	{
		if (strcmp( selector, kSelectorAIGetFileFormatParameters ) == 0)
		{
			error = GetFileFormatParameters((AIFileFormatMessage *)message);
		}
		else if (strcmp( selector, kSelectorAIGoFileFormat ) == 0)
		{
			error = GoFileFormat((AIFileFormatMessage *)message);
		}
		else if (strcmp( selector, kSelectorAICheckFileFormat ) == 0)
		{
			error = CheckFileFormat((AIFileFormatMessage *)message);
		}
		else if ( strcmp( selector, kSelectorAIUpdateFileFormat ) == 0 )
		{
			error = FileFormatUpdate( (AIUpdateFileFormatMessage *)message );
		}
		else if (!strcmp( selector, kDoActionSelector))
		{
			error = SetFileFormatParameters( (DoActionMessage *) message );
		}
	}
	else if (strcmp(caller, kCallerAITool) == 0)
	{
		if (strcmp( selector, kSelectorAIEditToolOptions ) == 0)
		{
			error = EditTool((AIToolMessage *)message);
		}
		else if (strcmp( selector, kSelectorAITrackToolCursor ) == 0)
		{
			error = TrackToolCursor((AIToolMessage *)message);
		}
		else if (strcmp( selector, kSelectorAIToolMouseDown ) == 0)
		{
			error = ToolMouseDown((AIToolMessage *)message);
			sAIUser->MessageAlert(ai::UnicodeString("Mouse down"));
		}
		else if (strcmp( selector, kSelectorAIToolMouseDrag ) == 0)
		{
			error = ToolMouseDrag((AIToolMessage *)message);
		}
		else if (strcmp( selector, kSelectorAIToolMouseUp ) == 0)
		{
			sAIUser->MessageAlert(ai::UnicodeString("Mouse up"));
			//error = ToolMouseUp((AIToolMessage *)message);
		}
		else if (strcmp( selector, kSelectorAISelectTool ) == 0)
		{
			error = SelectTool((AIToolMessage *)message);
		}
		else if (strcmp( selector, kSelectorAIDeselectTool ) == 0)
		{
			error = DeselectTool((AIToolMessage *)message);
		}
		else if (strcmp( selector, kSelectorAIReselectTool ) == 0)
		{
			error = ReselectTool((AIToolMessage *)message);
		}
		else if (strcmp( selector, kSelectorAIToolDecreaseDiameter ) == 0)
		{
			error = DecreaseDiameter((AIToolMessage *)message);
		}
		else if (strcmp( selector, kSelectorAIToolIncreaseDiameter ) == 0)
		{
			error = IncreaseDiameter((AIToolMessage *)message);
		}
		

	} else if (strcmp(caller, kCallerAILiveEffect ) == 0)
	{
		if (strcmp( selector, kSelectorAIEditLiveEffectParameters ) == 0)
		{
			error = EditLiveEffectParameters((AILiveEffectEditParamMessage *)message);
		}
		else if (strcmp( selector, kSelectorAIGoLiveEffect ) == 0)
		{
			error = GoLiveEffect((AILiveEffectGoMessage *)message);
		}
		else if (strcmp( selector, kSelectorAILiveEffectInterpolate ) == 0)
		{
			error = LiveEffectInterpolate((AILiveEffectInterpParamMessage *)message);
		}
		else if (strcmp( selector, kSelectorAILiveEffectInputType ) == 0)
		{
			error = LiveEffectGetInputType((AILiveEffectInputTypeMessage *)message);
		}
		else if (strcmp( selector, kSelectorAILiveEffectScaleParameters ) == 0)
		{
			error = LiveEffectScaleParameters((AILiveEffectScaleParamMessage *)message);
		}
		else if (strcmp( selector, kSelectorAILiveEffectConverColorSpace ) == 0)
		{
			error = LiveEffectConvertColorSpace((AILiveEffectConvertColorMessage *)message);
		}
		else if (strcmp( selector, kSelectorAILiveEffectAdjustColors ) == 0)
		{
			error = LiveEffectAdjustColors((AILiveEffectAdjustColorsMessage *)message);
		}
		else if (strcmp( selector, kSelectorAILiveEffectHandleMerge ) == 0)
		{
			error = LiveEffectHandleMerge((AILiveEffectHandleMergeMessage *)message);
		}
	} else if (strcmp(caller, kCallerAITimer ) == 0)
	{
		if (strcmp( selector, kSelectorAIGoTimer ) == 0)
		{
			error = GoTimer((AITimerMessage *)message);
		}
	}
	else if (strcmp(caller, kCallerAIClipboard ) == 0)
	{
		if ( strcmp( selector, kSelectorAIGoClipboard ) == 0 )
			error = GoClipboard( (AIClipboardMessage *) message );

		else if ( strcmp( selector, kSelectorAICanCopyClipboard ) == 0 )
			error = CanCopyClipboard( (AIClipboardMessage *) message );

		else if ( strcmp( selector, kSelectorAICloneClipboard ) == 0 )
			error = CloneClipboard( (AIClipboardMessage *) message );

		else if ( strcmp( selector, kSelectorAIDisposeClipboard ) == 0 )
			error = DisposeClipboard( (AIClipboardMessage *) message );
	}
	else if (strcmp(caller, kAIWorkspaceCaller ) == 0)
	{
		if ( strcmp( selector, kAIWSWriteSelector ) == 0 )
			error = WorkspaceWrite( (AIWorkspaceMessage *) message );

		else if ( strcmp( selector, kAIWSRestoreSelector ) == 0 )
			error = WorkspaceRestore( (AIWorkspaceMessage *) message );

		else if ( strcmp( selector, kAIWSDefaultSelector ) == 0 )
			error = WorkspaceDefault( (AIWorkspaceMessage *) message );
	}
	return error;
}