Index: Copy Handler/COPY HANDLER.cpp =================================================================== diff -u -N -r009f23e5403b3c15bfceaab29e03f45ebdc50ab0 -r9b4010bc607fb69b676fddefa2e876396d00732d --- Copy Handler/COPY HANDLER.cpp (.../COPY HANDLER.cpp) (revision 009f23e5403b3c15bfceaab29e03f45ebdc50ab0) +++ Copy Handler/COPY HANDLER.cpp (.../COPY HANDLER.cpp) (revision 9b4010bc607fb69b676fddefa2e876396d00732d) @@ -23,7 +23,6 @@ #include "CfgProperties.h" #include "MainWnd.h" -#include "PluginCore.h" #include "..\common\ipcstructs.h" #ifdef _DEBUG Index: Copy Handler/Copy Handler.vcproj =================================================================== diff -u -N -r8b107d3effd15dee348a9b1ecf9700b741c42eb9 -r9b4010bc607fb69b676fddefa2e876396d00732d --- Copy Handler/Copy Handler.vcproj (.../Copy Handler.vcproj) (revision 8b107d3effd15dee348a9b1ecf9700b741c42eb9) +++ Copy Handler/Copy Handler.vcproj (.../Copy Handler.vcproj) (revision 9b4010bc607fb69b676fddefa2e876396d00732d) @@ -353,7 +353,8 @@ Description="Compiling resources $(InputPath)" CommandLine="$(SolutionDir)other\Scripts\Exe2Lng.exe "$(InputPath)" "$(InputDir)Scripts\header.lng" "$(InputDir)\chtmp.rc" "$(TargetDir)..\..\other\Langs\English.lng" "$(InputDir)resource.h" "$(DevEnvDir)..\..\vc7\atlmfc\include\afxres.h" rc.exe /l 0x409 /d "NDEBUG" /d "_AFXDLL" /fo"$(OutDir)\$(InputName).res" "$(InputDir)chtmp.rc" -del "$(InputDir)\chtmp.rc"" +del "$(InputDir)\chtmp.rc" +" Outputs="$(OutDir)\$(InputName).res"/> - - - - @@ -1488,15 +1483,6 @@ RelativePath="OptionsDlg.h"> - - - - - - - - + + 0) - m_lLockCount--; - if (m_lLockCount == 0) - { - Unload(false); - m_bNeedChange=false; - } - } - } - catch (CPluginException*) - { - m_cs.Unlock(); - throw; - } - - m_cs.Unlock(); -} Index: modules/App Framework/Plugin.h =================================================================== diff -u -N --- modules/App Framework/Plugin.h (revision 3e1186252ab31f63d86d86c4b0ff593cfffbefde) +++ modules/App Framework/Plugin.h (revision 0) @@ -1,125 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __PLUGIN_H__ -#define __PLUGIN_H__ - -#include "PluginCore.h" -#include "ExceptionEx.h" -#include "afxmt.h" - -typedef bool(*PFNINIT)(PFNEXTINFOPROC); -typedef bool(*PFNUNINIT)(); -typedef bool(*PFNGETINFO)(_PLUGININFO*); - -// error codes for plugins -#define PLERR_UNKNOWN 0 -#define PLERR_LOAD 1 -#define PLERR_UNLOAD 2 -#define PLERR_INIT 3 -#define PLERR_UNINIT 4 - -#define THROW_PLUGINEXCEPTIONEX(str_reason, filename, app_code, last_error) throw new CFileExceptionEx(__FILE__, __LINE__, __FUNCTION__, str_reason, filename, app_code, last_error) - -class CPluginException : public CExceptionEx -{ -public: - CPluginException(PCTSTR pszSrcFile, DWORD dwLine, PCTSTR pszFunc, PCTSTR pszReason, PCTSTR pszFilename, DWORD dwReason=PLERR_UNKNOWN, DWORD dwLastError=0) : CExceptionEx(pszSrcFile, dwLine, pszFunc, pszReason, dwReason, dwLastError) { SetFilename(pszFilename); }; - CPluginException(PCTSTR pszSrcFile, DWORD dwLine, PCTSTR pszFunc, TCHAR* pszReason, PCTSTR pszFilename, DWORD dwReason=PLERR_UNKNOWN, DWORD dwLastError=0) : CExceptionEx(pszSrcFile, dwLine, pszFunc, pszReason, dwReason, dwLastError) { SetFilename(pszFilename); }; - virtual ~CPluginException() { delete [] m_pszFilename; }; - - virtual int RegisterInfo(__EXCPROPINFO* pInfo) - { - // if the pInfo is null - return count of a needed props - if (pInfo == NULL) - return 1+CExceptionEx::RegisterInfo(NULL); - - // call base class RegisterInfo - size_t tIndex=CExceptionEx::RegisterInfo(pInfo); - - // function has to register the info to be displayed (called from within GetInfo) - RegisterProp(pInfo+tIndex+0, _T("Plugin path"), PropType::dtPtrToString, &m_pszFilename); - - return 1; - }; - - -protected: - void SetFilename(PCTSTR pszFilename) { if (pszFilename) { m_pszFilename=new TCHAR[_tcslen(pszFilename)+1]; _tcscpy(m_pszFilename, pszFilename); } else m_pszFilename=NULL; }; - -public: - TCHAR *m_pszFilename; // name of the plugin -}; - -// plugin load state definitions -#define PLGS_NOTLOADED 0 /* plugin wasn't loaded yet */ -#define PLGS_LOADED 1 /* plugin has been loaded and is ready to use */ -#define PLGS_PARTIAL 2 /* plugin was once loaded and then unloaded->partial data is available */ - -class CPlugin -{ -public: - CPlugin(bool bInternal=false); - ~CPlugin(); - - void Load(PCTSTR pszName, PFNEXTINFOPROC pfn); // opens .dll file as a plugin & initializes it - void Unload(bool bCompletely=false); // unloads .dll (partially or completely) & deinitializes - - virtual void Init(PFNEXTINFOPROC pfn); // initializes this plugin with some callback - virtual void Uninit(); // uninitializes this plugin - - virtual bool GetInfo(_PLUGININFO* pInfo); // gets info about this plugin (use cache when possible) - - BYTE GetLoadState() { return m_byLoadState; }; - HMODULE GetModule() { return m_hModule; }; - bool IsInternal() { return m_bInternal; }; - - void BeginUsage(); // should be used before using function of a plugin - void EndUsage(); // should be used after using any plugin func - - // for use with internal plugins - void SetPluginInfo(_PLUGININFO* pData) { m_ppdData=pData; }; // sets the pointer - -protected: - virtual bool LoadExports(); // loads addresses of exported functions (from dll) - virtual void FreePluginData() { }; // for use in derived classes - have to free internal entries - - -protected: - TCHAR *m_pszFilename; // for external plugins - path to plugin, internal - handle to app hModule - HMODULE m_hModule; // dll address/app address - bool m_bInternal; // is this an internal plugin - BYTE m_byLoadState; // load state of this plugin - bool m_bNeedChange; // plugin was temporarily loaded from partial state - unload at the first occasion - - LONG volatile m_lLockCount; // for usage with partial state (specifies current count of loads) - CCriticalSection m_cs; - - PFNEXTINFOPROC m_pfnCallback; // address of a callback - - // cached data - _PLUGININFO* m_ppdData; // cached plugin data - - // exports addresses - PFNINIT m_pfnInit; - PFNUNINIT m_pfnUninit; - PFNGETINFO m_pfnGetInfo; -}; - -#endif \ No newline at end of file Index: modules/App Framework/PluginContainer.cpp =================================================================== diff -u -N --- modules/App Framework/PluginContainer.cpp (revision 7d997aef1e72f049ed1bc199e1b765d737d9963a) +++ modules/App Framework/PluginContainer.cpp (revision 0) @@ -1,143 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#include "stdafx.h" -#include "PluginContainer.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -// member functions -CPluginContainer::CPluginContainer() -{ - -} - -CPluginContainer::~CPluginContainer() -{ - Close(); -} - -// scans (recursively) a folder for plugins that meet uiType criteria -void CPluginContainer::Scan(PCTSTR pszFolder, UINT uiType) -{ - // before we scan... - Prescan(pszFolder, uiType); - - // place for additional "\*.dll" - TCHAR *pszPath=new TCHAR[_tcslen(pszFolder)+7]; - _tcscpy(pszPath, pszFolder); - _tcscat(pszPath, _T("\\*.dll")); - - WIN32_FIND_DATA wfd; - CPlugin* pplg=NULL; - _PLUGININFO pi; - HANDLE hFind=FindFirstFile(pszPath, &wfd); - BOOL bFnd=TRUE; - TCHAR szPluginPath[_MAX_PATH]; - while (hFind != INVALID_HANDLE_VALUE && bFnd) - { - // found next file - establish full path to that file - _tcscpy(szPluginPath, pszFolder); - _tcscat(szPluginPath, _T("\\")); - _tcscat(szPluginPath, wfd.cFileName); - - // load external plugin - pplg=NewPlugin(); - try - { - pplg->Load(szPluginPath, m_pfnCallback); - - // get info about this plugin - if (!pplg->GetInfo(&pi) || !(pi.uiMask & uiType)) - { - pplg->Unload(true); - FreePlugin(pplg); - } - else - Add(pplg, &pi); // add to internal storage structure - } - catch (CPluginException* e) - { - FreePlugin(pplg); - delete e; - } - - // and next plugin to go - bFnd=FindNextFile(hFind, &wfd); - } - - // delete not needed pplg - delete pszPath; - Postscan(pszFolder, uiType); -} - -ULONGLONG CPluginContainer::Add(CPlugin* tPlugin, _PLUGININFO* ppi) -{ - UINT uiRes=OnPluginLoading(tPlugin, ppi); - if (uiRes == PL_REMOVE) - { - // plugin cannot be loaded - tPlugin->Unload(true); - FreePlugin(tPlugin); - return (ULONGLONG)-1; - } - else - { - // add plugin - if (uiRes == PL_ADDUNLOADED) - tPlugin->Unload(false); - - // add - m_mPlugins.insert(plugin_map::value_type(ppi->uliSignature.QuadPart, tPlugin)); - - // plugin has been successfully loaded into memory - OnPluginLoaded(tPlugin, ppi); - } - - return ppi->uliSignature.QuadPart; -} - -void CPluginContainer::Remove(ULONGLONG uiID) -{ - plugin_map::iterator it=m_mPlugins.find(uiID); - if (it != m_mPlugins.end()) - { - CPlugin* pplg=it->second; - - pplg->Unload(true); - FreePlugin(pplg); - m_mPlugins.erase(uiID); - } -} - -void CPluginContainer::Close() -{ - plugin_map::const_iterator it=m_mPlugins.begin(); - CPlugin *pplg; - while (it != m_mPlugins.end()) - { - pplg=it->second; - pplg->Unload(true); - FreePlugin(pplg); - it++; - } - m_mPlugins.clear(); -} Index: modules/App Framework/PluginContainer.h =================================================================== diff -u -N --- modules/App Framework/PluginContainer.h (revision 3e1186252ab31f63d86d86c4b0ff593cfffbefde) +++ modules/App Framework/PluginContainer.h (revision 0) @@ -1,61 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __PLUGINCONTAINER_H__ -#define __PLUGINCONTAINER_H__ - -#include -#include "Plugin.h" - -using namespace std; - -// constants - used in OnPluginLoading for determining action for plugin -#define PL_REMOVE 0 -#define PL_ADDUNLOADED 1 -#define PL_ADD 2 - -class CPluginContainer -{ -public: - CPluginContainer(); - ~CPluginContainer(); - - void Scan(PCTSTR pszFolder, UINT uiType); // scans for external plugins - ULONGLONG Add(CPlugin* tPlugin, _PLUGININFO* ppi); // adds plugin to plugin map - void Remove(ULONGLONG uiID); // removes plugin from map - void Close(); - - virtual CPlugin* NewPlugin() { return new CPlugin(); }; // allocates mem for plugin (depends on container type) - virtual void FreePlugin(CPlugin* pPlugin) { delete pPlugin; }; - - virtual void Prescan(PCTSTR /*pszFolder*/, UINT /*uiType*/) { }; // called before scanning - virtual void Postscan(PCTSTR /*pszFolder*/, UINT /*uiType*/) { }; // after scanning finished - - virtual UINT OnPluginLoading(CPlugin* /*tPlugin*/, _PLUGININFO* /*pInfo*/) { return PL_ADD; }; // plugin found/parially loaded - // - what to do ? - virtual void OnPluginLoaded(CPlugin* /*tPlugin*/, _PLUGININFO* /*pInfo*/) { }; // plugin has been added to a list - -public: - typedef map plugin_map; - PFNEXTINFOPROC m_pfnCallback; // callback for plugin usage - communication with app - plugin_map m_mPlugins; -}; - - -#endif Index: modules/App Framework/PluginCore.h =================================================================== diff -u -N --- modules/App Framework/PluginCore.h (revision 3e1186252ab31f63d86d86c4b0ff593cfffbefde) +++ modules/App Framework/PluginCore.h (revision 0) @@ -1,49 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __PLUGINCORE_H__ -#define __PLUGINCORE_H__ - -typedef LRESULT(*PFNEXTINFOPROC)(ULONGLONG dwModuleID, UINT uMsg, WPARAM wParam, LPARAM lParam); - -// plugin structures -struct _PLUGININFO -{ - ULONG ulSize; // size of this structure - ULARGE_INTEGER uliSignature; // 64-bit unique ID of this plugin - - char szProgID[32]; // program string identificator for which this plugin was written - current "1.x" - UINT uiMask; // what this dll can do (type of this plugin - PT_... value) - - char szPluginName[128]; // full name of this plugin (preferred english description) - struct _VERSION - { - WORD wMajor; - WORD wMinor; - WORD wRelease; - WORD wBuild; - } vVersion; // plugin version - char szAuthor[128]; // name of the author (or company name or both) - char szPluginDescription[256]; // plugin info - what it can do, ... (preferred english) - - // update info - char szUpdateInfo[256]; // internet address of a file with new plugin info (address, version, ...). Currently unused, but may be in future. -}; - -#endif \ No newline at end of file