//========================================================================= // CPADLLli.cpp : implementation of the CPA_DLLList class // // This is a part of the CPA project. // // Version 1.0 // Creation date 10/06/96 // Revision date // // (c) Ubi Studios 1996 // // DO NOT MODIFY THAT FILE. IF SOMETHING NEEDS TO BE CHANGE, PLEASE CONTACT // VINCENT GRECO OR CHRISTOPHE BEAUDET. //========================================================================= #include "stdafx.h" #ifdef ACTIVE_EDITOR #include "acp_base.h" #include "itf/CPADllls.hpp" #include "itf/CPAMWorl.hpp" #include "itf/CPACont.hpp" #include #include "itf/CPAConst.hpp" #include "itf/CPAInter.hpp" #include "acp_driver.h" //*********************************************** //*** DR (20/01/98) ***************************** HMODULE g_hWawModule = NULL; //*** End DR ************************************ //*********************************************** //=========================================================================== // constructor //=========================================================================== CPA_DLLList::CPA_DLLList() { m_uwCurrentRef = 1; m_lObjectDLLCount = 0; m_lToolDLLCount = 0; } CPA_DLLList::~CPA_DLLList() { tdstDLLIdentity *p_stDLLId; POSITION xPos; // destroy all instances of DLL xPos = m_oListOfDLLIdentities . GetHeadPosition(); while( xPos ) { p_stDLLId = m_oListOfDLLIdentities . GetNext( xPos ); if (p_stDLLId->p_oListOfInstances != NULL) { // if there are some instances of this DLL left while (!(p_stDLLId->p_oListOfInstances->IsEmpty())) { // then delete them /*delete*/ p_stDLLId->p_oListOfInstances->RemoveHead(); } // list of instances is static, so don't delete it } //DLL identity is static, so don't delete it //but remove the DLL library from memory } while(!(m_oListOfDLLIdentities.IsEmpty())) { p_stDLLId = m_oListOfDLLIdentities.RemoveHead(); FreeLibrary(p_stDLLId->hModule); } } //=========================================================================== // Description: Load all DLL from objects and tools directory // Creation date: 10 Jun 96 // Author: //--------------------------------------------------------------------------- // eType type of DLL // p_oDLL the DLL interface // Return void //--------------------------------------------------------------------------- // Revision date: Author: //=========================================================================== HANDLE fn_hFindGoodDll(WIN32_FIND_DATA *p_stFileInfo) { #ifdef _DEBUG #ifdef TEST_CPA_VERSION_3D return FindFirstFile("*P5_?t.dll", p_stFileInfo); #endif #ifdef USE_DIRECTX if ((GLI_lWhatIsGLI() == GLI_C_VersionGlide) || (GLI_lWhatIsGLI() ==GLI_C_VersionD3DDP)) //chbani return FindFirstFile("*DFE?d.dll", p_stFileInfo); return FindFirstFile("*P5E?d.dll", p_stFileInfo); #else if ((GLI_lWhatIsGLI() == GLI_C_VersionGlide) ) return FindFirstFile("*DFE?d.dll", p_stFileInfo); return FindFirstFile("*P5E?d.dll", p_stFileInfo); #endif #else if (GLI_lWhatIsGLI() == GLI_C_VersionGlide) return FindFirstFile("*DFE?r.dll", p_stFileInfo); return FindFirstFile("*P5E?r.dll", p_stFileInfo); #endif } void CPA_DLLList::LoadAllDLL() { WIN32_FIND_DATA *p_stFileInfo; tdstDLLFiles *p_stDLLFile; HANDLE hFirstFile; CList oListOfDLLFiles; //--------------------------------------------------- // let's look for hierarchy DLL p_stFileInfo = new WIN32_FIND_DATA; hFirstFile = fn_hFindGoodDll(p_stFileInfo); if(hFirstFile == INVALID_HANDLE_VALUE) { MessageBox(NULL,"There's no Hierarchy DLL", "Warning",MB_OK|MB_ICONWARNING|MB_TASKMODAL); } else { do { p_stDLLFile = new tdstDLLFiles; p_stDLLFile->p_stFileInfo = p_stFileInfo; p_stDLLFile->bAlreadyLoaded = FALSE; p_stDLLFile->csPath = ""; oListOfDLLFiles.AddTail(p_stDLLFile); p_stFileInfo = new WIN32_FIND_DATA; } while(FindNextFile(hFirstFile,p_stFileInfo)); FindClose(hFirstFile); } delete p_stFileInfo; //--------------------------------------------------- // let's look for objects DLL if(chdir("Objects") == -1) { MessageBox(NULL,"Unable to find 'EDT_DATA\\Objects' directory. Can't load Objects DLL.", "Warning",MB_OK|MB_ICONWARNING|MB_TASKMODAL); } else { p_stFileInfo = new WIN32_FIND_DATA; hFirstFile = fn_hFindGoodDll(p_stFileInfo); if(hFirstFile == INVALID_HANDLE_VALUE) { MessageBox(NULL,"There's no DLL in 'Objects' directory", "Warning",MB_OK|MB_ICONWARNING|MB_TASKMODAL); } else { do { p_stDLLFile = new tdstDLLFiles; p_stDLLFile->p_stFileInfo = p_stFileInfo; p_stDLLFile->bAlreadyLoaded = FALSE; p_stDLLFile->csPath = "Objects"; oListOfDLLFiles.AddTail(p_stDLLFile); p_stFileInfo = new WIN32_FIND_DATA; } while(FindNextFile(hFirstFile,p_stFileInfo)); FindClose(hFirstFile); } delete p_stFileInfo; chdir(".."); } //--------------------------------------------------- //let's look for tools DLL if(chdir("Tools") == -1) { MessageBox(NULL,"Unable to find 'EDT_DATA\\Tools' directory. Can't load Tools DLL.", "Warning",MB_OK|MB_ICONWARNING|MB_TASKMODAL); } else { p_stFileInfo = new WIN32_FIND_DATA; hFirstFile = fn_hFindGoodDll(p_stFileInfo); if(hFirstFile == INVALID_HANDLE_VALUE) { MessageBox(NULL,"There's no DLL in 'Tools' directory", "Warning",MB_OK|MB_ICONWARNING|MB_TASKMODAL); } else { do { p_stDLLFile = new tdstDLLFiles; p_stDLLFile->p_stFileInfo = p_stFileInfo; p_stDLLFile->bAlreadyLoaded = FALSE; p_stDLLFile->csPath = "Tools"; oListOfDLLFiles.AddTail(p_stDLLFile); p_stFileInfo = new WIN32_FIND_DATA; } while(FindNextFile(hFirstFile,p_stFileInfo)); FindClose(hFirstFile); } delete p_stFileInfo; chdir(".."); } //load all dLLS LoadAllDLLsFromList(&oListOfDLLFiles); // delete load list while (!(oListOfDLLFiles.IsEmpty())) { p_stDLLFile = oListOfDLLFiles.RemoveHead(); delete p_stDLLFile->p_stFileInfo; delete p_stDLLFile; } } //=========================================================================== // Description: Get a new DLL with the given name and type // Creation date: // Author: //--------------------------------------------------------------------------- CPA_DLLBase *CPA_DLLList::GetANewDLL(tdeDLLType eType,CString csName, long lKey) { tdstDLLIdentity *p_stMatchingDLL; tdstDLLIdentity stDLLId; CPA_DLLBase *p_oDLL; FARPROC DllAdr; CString csMsg; //let's find the DLL with the given name and type stDLLId.csName = csName; stDLLId.eType = eType; p_stMatchingDLL = GetAllreadyRegisteredDLLId(&stDLLId); // ok? if (p_stMatchingDLL == NULL) { csMsg = csName + " : this DLL has not been registered"; AfxMessageBox(csMsg); return NULL; } // we found the right DLL DllAdr = GetProcAddress(p_stMatchingDLL->hModule, "fn_p_oGetDLL"); if(DllAdr == NULL) { csMsg = csName + " : Unable to find fn_p_oGetDLL function "; AfxMessageBox(csMsg); return NULL; } p_oDLL = (CPA_DLLBase*) (((int (__stdcall *)(long))DllAdr)(lKey)); // if the requester was not authorized to get this DLL if (p_oDLL == NULL) return NULL; // if instance allready exists, don't register it twice if (!(p_stMatchingDLL->p_oListOfInstances->Find(p_oDLL))) { // set DLL reference in the DLLBase structure p_oDLL->SetReference(m_uwCurrentRef++); // add the DLL to the list of instances p_stMatchingDLL->p_oListOfInstances->AddTail(p_oDLL); } return p_oDLL; } //=========================================================================== // Description: Get a new instance of every present DLL // Creation date: // Author: //--------------------------------------------------------------------------- long CPA_DLLList::GetAllNewDLL(tdeDLLType eType,CPA_DLLBase *ap_oDLL[], long lKey) { POSITION stPos; tdstDLLIdentity *p_stDLLId; long lNbOfDLL; CPA_DLLBase *p_oDLL; FARPROC DllAdr; stPos = m_oListOfDLLIdentities.GetHeadPosition(); lNbOfDLL = 0; if (eType == ALL_OBJECTS_DLL) eType = OBJECT_DLL; if (eType == ALL_TOOLS_DLL) eType = TOOL_DLL; while (stPos != NULL) { p_stDLLId = (m_oListOfDLLIdentities.GetNext(stPos)); if(p_stDLLId->eType == eType) { // we found one ! DllAdr = GetProcAddress(p_stDLLId->hModule, "fn_p_oGetDLL"); if(DllAdr == NULL) { CString csMsg; csMsg = p_stDLLId->csName + " : Unable to find fn_p_oGetDLL function "; AfxMessageBox(csMsg); return NULL; } p_oDLL = (CPA_DLLBase*) (((int (__stdcall *)(long))DllAdr)(lKey)); // if the requester was not authorized to get this DLL if (p_oDLL == NULL) continue; // if instance allready exists, don't register it twice if (!(p_stDLLId->p_oListOfInstances->Find(p_oDLL))) { // set DLL reference in the DLLBase structure p_oDLL->SetReference(m_uwCurrentRef++); // add the DLL to the list of instances p_stDLLId->p_oListOfInstances->AddTail(p_oDLL); } ap_oDLL[lNbOfDLL++] = p_oDLL; } } return lNbOfDLL; } //=========================================================================== // Description: remove and delete an instance of DLL // Creation date: // Author: //--------------------------------------------------------------------------- void CPA_DLLList::DestroyADLL(CPA_DLLBase *p_oDLL) { tdstDLLIdentity *p_stDLLId; CList *p_oListOfInstances; POSITION stPos; //let's find the DLL identity p_stDLLId = p_oDLL->GetDLLIdentity(); // let's get the list of instances p_oListOfInstances = p_stDLLId->p_oListOfInstances; // let's find this DLL in the list stPos = p_oListOfInstances->Find(p_oDLL); if (stPos == NULL) { ASSERT(0); return; } // remove the DLL p_oListOfInstances->RemoveAt(stPos); // delete the DLL delete p_oDLL; } //=========================================================================== // Description: Add a DLL to the list. // Creation date: 10 Jun 96 // Author: //--------------------------------------------------------------------------- // eType type of DLL // p_oDLL the DLL interface // Return void //--------------------------------------------------------------------------- // Revision date: Author: //=========================================================================== void CPA_DLLList::AddADLL(tdstDLLIdentity *p_stDLLIdentity) { // check if DLL allready exists if (GetAllreadyRegisteredDLLId(p_stDLLIdentity) != NULL) { CString csMsg; csMsg = p_stDLLIdentity->csName + " : That DLL is allready registered"; AfxMessageBox(csMsg); } else { m_oListOfDLLIdentities.AddTail(p_stDLLIdentity); switch (p_stDLLIdentity->eType) { case OBJECT_DLL: m_lObjectDLLCount++; break; case TOOL_DLL: m_lToolDLLCount++; break; } } } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------Object DLL Specific------------------------------------------------ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ //-----------------------------PRIVATE------------------------------------------ //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ //=========================================================================== // Description: This is the function that load, check and register all DLLs // of the given list // Creation date: 23 Sep 96 // Author: FBF //--------------------------------------------------------------------------- // Revision date: // Author: //=========================================================================== void CPA_DLLList::LoadAllDLLsFromList(CList *p_oListOfDLLFiles) { HMODULE hModule; FARPROC DllAdr; // char *p_szCPAVersion; tdstDLLIdentity *p_stDLLIdentity; POSITION stPos; BOOL bNewLoaded; long lNbLoaded; tdstDLLFiles *p_stDLLFile; bNewLoaded = TRUE; lNbLoaded = 0; /////////////////////////// /////////////////////////// // YB (07/01/98) #ifdef _DEBUG HMODULE hMyModule = (HMODULE)LoadLibrary("ErO___vd.dll");; #else HMODULE hMyModule = (HMODULE)LoadLibrary("ErO___vr.dll");; #endif //_DEBUG if ( hMyModule != NULL ) { FARPROC FPMyFunction = GetProcAddress(hMyModule, "ERO_fn_vInitModule"); void (* MyFunction)(HMODULE) = (void (__cdecl *)(HMODULE))FPMyFunction; if ( MyFunction != NULL ) MyFunction(hMyModule); else AfxMessageBox("Function has not been found in DLL (ErO module)"); } else AfxMessageBox("DLL could not be loaded (ErO module)"); // End YB (07/01/98) /////////////////////////// /////////////////////////// /////////////////////////// /////////////////////////// // YB (07/01/98) #ifdef _DEBUG HMODULE hMyOtherModule = (HMODULE)LoadLibrary("CTL___vd.dll");; #else HMODULE hMyOtherModule = (HMODULE)LoadLibrary("CTL___vr.dll");; #endif //_DEBUG if ( hMyOtherModule != NULL ) { FARPROC FPMyFunction = GetProcAddress(hMyOtherModule, "CTL_fn_vInitModule"); void (* MyFunction)(HMODULE) = (void (__cdecl *)(HMODULE))FPMyFunction; if ( MyFunction != NULL ) MyFunction(hMyOtherModule); else AfxMessageBox("Function has not been found in DLL (CTL module)"); } else AfxMessageBox("DLL could not be loaded (CTL module)"); // End YB (07/01/98) /////////////////////////// /////////////////////////// //************************************* //*** DR (20/01/98) ******************* #ifdef _DEBUG g_hWawModule = (HMODULE)LoadLibrary("WAW___vd.dll"); #else g_hWawModule = (HMODULE)LoadLibrary("WAW___vr.dll"); #endif //_DEBUG if( g_hWawModule != NULL ) { void (*WawInitFunction)(HMODULE) = (void (__cdecl*)(HMODULE))GetProcAddress( g_hWawModule, "WAW_fn_vInitModule" ); if( WawInitFunction != NULL ) WawInitFunction( g_hWawModule ); else AfxMessageBox("Function has not been found in DLL (WAW module)"); } else AfxMessageBox("DLL could not be loaded (WAW module)"); #if 0 //mchbani POSITION stPos2,stCurrentPos; tdstDLLFiles *p_stDLLFile2; stPos = p_oListOfDLLFiles->GetHeadPosition(); while(stPos) { CString strErr; CString strName; // get DLLFile p_stDLLFile = p_oListOfDLLFiles->GetNext(stPos); strstr(p_stDLLFile->p_stFileInfo->cFileName,"DX"); //strName.Format(p_stDLLFile->p_stFileInfo->cFileName); //if(strName.Find("DX")) if( strstr(p_stDLLFile->p_stFileInfo->cFileName,"DX") ) { stPos2 = p_oListOfDLLFiles->GetHeadPosition(); while(stPos2) { CString strName2; stCurrentPos =stPos2; p_stDLLFile2 = p_oListOfDLLFiles->GetNext(stPos2); //strName2.Format(p_stDLLFile2->p_stFileInfo->cFileName); if( (p_stDLLFile != p_stDLLFile2) && strncmp( p_stDLLFile->p_stFileInfo->cFileName , p_stDLLFile2->p_stFileInfo->cFileName,3)==0) { strErr.Format("DLL duplicated : %s --- %s\n ", p_stDLLFile2->p_stFileInfo->cFileName, p_stDLLFile->p_stFileInfo->cFileName); // p_stDLLFile2->bAlreadyLoaded = TRUE; p_oListOfDLLFiles->RemoveAt(stCurrentPos); AfxMessageBox(strErr); } } } } #endif //emc //*** DR (20/01/98) ******************* //************************************* // stop when the hole list is loaded, or when one pass didn't load anything while (lNbLoaded != p_oListOfDLLFiles->GetCount() && bNewLoaded ) { // reset flag bNewLoaded = FALSE; // move to beginning of the list stPos = p_oListOfDLLFiles->GetHeadPosition(); // while end of list not reached while(stPos) { // get DLLFile p_stDLLFile = p_oListOfDLLFiles->GetNext(stPos); // if not already loaded if (!(p_stDLLFile->bAlreadyLoaded)) { // try to load // go to good directory chdir(p_stDLLFile->csPath); //load hModule = (HMODULE) LoadLibrary(p_stDLLFile->p_stFileInfo->cFileName); //come back to old path if (!p_stDLLFile->csPath.IsEmpty()) chdir(".."); if (hModule == NULL) { CString strErr; TCHAR strDir[MAX_PATH]; GetCurrentDirectory(MAX_PATH, strDir); strErr.Format("Failed to load : %s\\%s from\n%s", p_stDLLFile->csPath, p_stDLLFile->p_stFileInfo->cFileName, strDir); AfxMessageBox(strErr); } if(hModule != NULL) { CString csMsg; // success, DLL loaded p_stDLLFile->bAlreadyLoaded = TRUE; bNewLoaded = TRUE; lNbLoaded++; //---------------------------------------------------------------------- // load DLL Identity structure //---------------------------------------------------------------------- DllAdr = GetProcAddress(hModule, "fn_p_stGetDLLIdentity"); if(DllAdr == NULL) { csMsg.Format("%s : Unable to find fn_p_stGetDLLIdentity function",p_stDLLFile->p_stFileInfo->cFileName); AfxMessageBox(csMsg); continue; } p_stDLLIdentity = (tdstDLLIdentity*)DllAdr(); //---------------------------------------------------------------------- // Init DLL //---------------------------------------------------------------------- DllAdr = GetProcAddress(hModule, "fn_vInitDll"); if(DllAdr == NULL) { csMsg = p_stDLLIdentity->csName + " : Unable to find fn_vInitDll function"; AfxMessageBox(csMsg); continue; } DllAdr(); //---------------------------------------------------------------------- // Verify CPA version //---------------------------------------------------------------------- /* DllAdr = GetProcAddress(hModule, "fn_p_szGetCPAVersion"); if(DllAdr == NULL) { csMsg = p_stDLLIdentity->csName + " : Unable to find fn_p_szGetCPAVersion function"; AfxMessageBox(csMsg); continue; } p_szCPAVersion = (char *) DllAdr(); if(strcmp(p_szCPAVersion, C_szCPAVersion)) { csMsg = p_stDLLIdentity->csName + " : Bad CPA version"; AfxMessageBox(csMsg); continue; }*/ // OK, now we have a good DLL, let's register it p_stDLLIdentity->hModule = hModule; AddADLL(p_stDLLIdentity); } } } } // finished, check: if (lNbLoaded != p_oListOfDLLFiles->GetCount()) { // some DLL have not been loaded CString csTotalMsg; CString csMsg; csTotalMsg = "The following DLL couldn't be loaded :\n\n"; stPos = p_oListOfDLLFiles->GetHeadPosition(); while (stPos) { // get DLLFile p_stDLLFile = p_oListOfDLLFiles->GetNext(stPos); // if not already loaded if (!(p_stDLLFile->bAlreadyLoaded)) { //Add name to message csMsg.Format("%s\n",p_stDLLFile->p_stFileInfo->cFileName); csTotalMsg += csMsg; } } AfxMessageBox(csTotalMsg); } } //=========================================================================== // Description: check if the given DLL identity allready exists // Creation date: 10 Jun 96 // Author: FBF //--------------------------------------------------------------------------- // Revision date: Author: //=========================================================================== tdstDLLIdentity *CPA_DLLList::GetAllreadyRegisteredDLLId(tdstDLLIdentity *p_stDLLIdentity) { POSITION stPos; tdstDLLIdentity *p_stDLLId; stPos = m_oListOfDLLIdentities.GetHeadPosition(); while (stPos != NULL) { p_stDLLId = (m_oListOfDLLIdentities.GetNext(stPos)); if( (p_stDLLId->eType == p_stDLLIdentity->eType) && (p_stDLLId->csName == p_stDLLIdentity->csName) ) return p_stDLLId; } return NULL; } void CPA_DLLList::CallRefreshDatas() { POSITION stPos,stPos2; CPA_DLLBase *p_oDLL; tdstDLLIdentity *p_stDLLId; CList *p_oListOfDLL; stPos = m_oListOfDLLIdentities.GetHeadPosition(); while(stPos != NULL) { p_stDLLId = m_oListOfDLLIdentities.GetNext(stPos); p_oListOfDLL = p_stDLLId->p_oListOfInstances; stPos2 = p_oListOfDLL->GetHeadPosition(); while(stPos2 != NULL) { p_oDLL = p_oListOfDLL->GetNext(stPos2); if (p_oDLL->GetBaseDefinition()->bCanBeRefreshedByEngine) p_oDLL->fn_vRefreshDatas(); } } } BOOL CPA_DLLList::CallAcceptToRunEngine() { POSITION stPos,stPos2; CPA_DLLBase *p_oDLL; tdstDLLIdentity *p_stDLLId; CList *p_oListOfDLL; DEV_MultiDevice *p_oMultiDevice; CPA_EditorBase *p_oEvtEdt; stPos = m_oListOfDLLIdentities.GetHeadPosition(); while(stPos != NULL) { p_stDLLId = m_oListOfDLLIdentities.GetNext(stPos); p_oListOfDLL = p_stDLLId->p_oListOfInstances; stPos2 = p_oListOfDLL->GetHeadPosition(); while(stPos2 != NULL) { p_oDLL = p_oListOfDLL->GetNext(stPos2); if (p_oDLL->fn_bAcceptToRunEngine() == FALSE) return FALSE; } } stPos = m_oListOfMultiDevices.GetHeadPosition(); while(stPos != NULL) { CPA_Interface *p_oInterface; p_oMultiDevice = m_oListOfMultiDevices.GetNext(stPos); p_oInterface = p_oMultiDevice->GetInterface(); if (p_oInterface && ((p_oEvtEdt = p_oInterface->GetEditor()) != NULL)) { if (p_oEvtEdt->fn_bAcceptToRunEngine() == FALSE) return FALSE; } } return TRUE; } void CPA_DLLList::CallBeforeEngine() { POSITION stPos,stPos2; CPA_DLLBase *p_oDLL; tdstDLLIdentity *p_stDLLId; CList *p_oListOfDLL; DEV_MultiDevice *p_oMultiDevice; CPA_EditorBase *p_oEvtEdt; // Begin Silviu Simen Cut of Special Objs stPos = m_oListOfDLLIdentities.GetHeadPosition(); while(stPos != NULL) { p_stDLLId = m_oListOfDLLIdentities.GetNext(stPos); p_oListOfDLL = p_stDLLId->p_oListOfInstances; stPos2 = (p_stDLLId->eType == HIERARCHY_DLL) ? p_oListOfDLL->GetHeadPosition() : NULL; while(stPos2 != NULL) { p_oDLL = p_oListOfDLL->GetNext(stPos2); p_oDLL->fn_vBeforeEngine(); } } // End Silviu Simen Cut of Special Objs stPos = m_oListOfDLLIdentities.GetHeadPosition(); while(stPos != NULL) { p_stDLLId = m_oListOfDLLIdentities.GetNext(stPos); p_oListOfDLL = p_stDLLId->p_oListOfInstances; stPos2 = (p_stDLLId->eType != HIERARCHY_DLL) ? p_oListOfDLL->GetHeadPosition() : NULL; while(stPos2 != NULL) { p_oDLL = p_oListOfDLL->GetNext(stPos2); p_oDLL->fn_vBeforeEngine(); } } stPos = m_oListOfMultiDevices.GetHeadPosition(); while(stPos != NULL) { CPA_Interface *p_oInterface; p_oMultiDevice = m_oListOfMultiDevices.GetNext(stPos); p_oInterface = p_oMultiDevice->GetInterface(); if (p_oInterface && ((p_oEvtEdt = p_oInterface->GetEditor()) != NULL)) { p_oEvtEdt->fn_vBeforeEngine(); } } } void CPA_DLLList::CallBeforeEditor() { POSITION stPos,stPos2; CPA_DLLBase *p_oDLL; tdstDLLIdentity *p_stDLLId; CList *p_oListOfDLL; DEV_MultiDevice *p_oMultiDevice; CPA_EditorBase *p_oEvtEdt; // call interface & EvtEditor stPos = m_oListOfMultiDevices.GetHeadPosition(); while(stPos != NULL) { CPA_Interface *p_oInterface; p_oMultiDevice = m_oListOfMultiDevices.GetNext(stPos); if (p_oMultiDevice->IsActive()) { p_oInterface = p_oMultiDevice->GetInterface(); if (p_oInterface) p_oInterface->fn_vBeforeEditor(); p_oEvtEdt = p_oInterface->GetEditor(); if (p_oEvtEdt) p_oEvtEdt->fn_vBeforeEditor(); } } // call all DLLs but current ones stPos = m_oListOfDLLIdentities.GetHeadPosition(); while(stPos != NULL) { p_stDLLId = m_oListOfDLLIdentities.GetNext(stPos); p_oListOfDLL = p_stDLLId->p_oListOfInstances; stPos2 = (p_stDLLId->eType != HIERARCHY_DLL) ? p_oListOfDLL->GetHeadPosition() : NULL; while(stPos2 != NULL) { p_oDLL = p_oListOfDLL->GetNext(stPos2); if (!p_oDLL->fn_bIsCurrentEditor()) p_oDLL->fn_vBeforeEditor(); } } // call current Editor stPos = m_oListOfMultiDevices.GetHeadPosition(); while(stPos != NULL) { CPA_Interface *p_oInterface; p_oMultiDevice = m_oListOfMultiDevices.GetNext(stPos); if (p_oMultiDevice->IsActive()) { p_oInterface = p_oMultiDevice->GetInterface(); if (p_oInterface) { p_oEvtEdt = p_oInterface->GetEditor(); if (p_oEvtEdt && (p_oEvtEdt->GetMainWorld()->GetCurrentEditor() != p_oEvtEdt)) p_oEvtEdt->GetMainWorld()->GetCurrentEditor()->fn_vBeforeEditor(); p_oInterface->fn_vUpdateEditor(); } } } } void CPA_DLLList::CallJustBeforeClosing() { POSITION stPos,stPos2; CPA_DLLBase *p_oDLL; tdstDLLIdentity *p_stDLLId; CList *p_oListOfDLL; DEV_MultiDevice *p_oMultiDevice; CPA_EditorBase *p_oEvtEdt; stPos = m_oListOfDLLIdentities.GetHeadPosition(); while(stPos != NULL) { p_stDLLId = m_oListOfDLLIdentities.GetNext(stPos); p_oListOfDLL = p_stDLLId->p_oListOfInstances; stPos2 = p_oListOfDLL->GetHeadPosition(); while(stPos2 != NULL) { p_oDLL = p_oListOfDLL->GetNext(stPos2); p_oDLL->fn_vJustBeforeClosing(); } } stPos = m_oListOfMultiDevices.GetHeadPosition(); while(stPos != NULL) { CPA_Interface *p_oInterface; p_oMultiDevice = m_oListOfMultiDevices.GetNext(stPos); p_oInterface = p_oMultiDevice->GetInterface(); if (p_oInterface && ((p_oEvtEdt = p_oInterface->GetEditor()) != NULL)) { p_oEvtEdt->fn_vJustBeforeClosing(); } } } void CPA_DLLList::CallConstruct() { POSITION stPos,stPos2; CPA_DLLBase *p_oDLL; tdstDLLIdentity *p_stDLLId; CList *p_oListOfDLL; stPos = m_oListOfDLLIdentities.GetHeadPosition(); while(stPos != NULL) { p_stDLLId = m_oListOfDLLIdentities.GetNext(stPos); p_oListOfDLL = p_stDLLId->p_oListOfInstances; stPos2 = p_oListOfDLL->GetHeadPosition(); while(stPos2 != NULL) { p_oDLL = p_oListOfDLL->GetNext(stPos2); p_oDLL->fn_vConstruct(); } } } void CPA_DLLList::CallJustAfterRegistered() { POSITION stPos,stPos2; CPA_DLLBase *p_oDLL; tdstDLLIdentity *p_stDLLId; CList *p_oListOfDLL; stPos = m_oListOfDLLIdentities.GetHeadPosition(); while(stPos != NULL) { p_stDLLId = m_oListOfDLLIdentities.GetNext(stPos); p_oListOfDLL = p_stDLLId->p_oListOfInstances; stPos2 = p_oListOfDLL->GetHeadPosition(); while(stPos2 != NULL) { p_oDLL = p_oListOfDLL->GetNext(stPos2); p_oDLL->fn_vJustAfterRegistered(); } } } BOOL CPA_DLLList::CallAcceptToExit() { POSITION stPos,stPos2; CPA_DLLBase *p_oDLL; tdstDLLIdentity *p_stDLLId; CList *p_oListOfDLL; DEV_MultiDevice *p_oMultiDevice; CPA_EditorBase *p_oEvtEdt; stPos = m_oListOfDLLIdentities.GetHeadPosition(); while(stPos != NULL) { p_stDLLId = m_oListOfDLLIdentities.GetNext(stPos); p_oListOfDLL = p_stDLLId->p_oListOfInstances; stPos2 = p_oListOfDLL->GetHeadPosition(); while(stPos2 != NULL) { p_oDLL = p_oListOfDLL->GetNext(stPos2); if (p_oDLL->fn_bAcceptToExit() == FALSE) return FALSE; } } stPos = m_oListOfMultiDevices.GetHeadPosition(); while(stPos != NULL) { CPA_Interface *p_oInterface; p_oMultiDevice = m_oListOfMultiDevices.GetNext(stPos); p_oInterface = p_oMultiDevice->GetInterface(); if (p_oInterface && ((p_oEvtEdt = p_oInterface->GetEditor()) != NULL)) { if (p_oEvtEdt->fn_bAcceptToExit() == FALSE) return FALSE; } } return TRUE; } BOOL CPA_DLLList::CallPreTranslateMessage(MSG *p_stMsg) { POSITION stPos; DEV_MultiDevice *p_oMultiDevice; CPA_Contact *p_oContact; stPos = m_oListOfMultiDevices.GetHeadPosition(); while(stPos != NULL) { p_oMultiDevice = m_oListOfMultiDevices.GetNext(stPos); if ((p_oContact = p_oMultiDevice->GetContact()) != NULL) { if (p_oContact->fn_bPreTranslateMessage(p_stMsg) == TRUE) return TRUE; } } return FALSE; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------Object DLL Specific------------------------------------------------ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------Tool DLL Specific------------------------------------------------ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------MultiDevice Specific------------------------------------------------ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //=========================================================================== // Description: register a new multidevice // Creation date: // Author: //--------------------------------------------------------------------------- void CPA_DLLList::RegisterNewMultiDevice(DEV_MultiDevice *p_oMultiDevice) { m_oListOfMultiDevices.AddTail(p_oMultiDevice); } //=========================================================================== // Description: un-register the given multidevice // Creation date: // Author: //--------------------------------------------------------------------------- void CPA_DLLList::RemoveAMultiDevice(DEV_MultiDevice *p_oMD) { POSITION stPos; // find the multidevice stPos = m_oListOfMultiDevices.Find(p_oMD); if (stPos == NULL) { ASSERT(0); return; } // remove the multidevice m_oListOfMultiDevices.RemoveAt(stPos); } #endif // ACTIVE_EDITOR