OSDN Git Service

Remove FileTransform.h dependency from Plugins.cpp
authorsdottaka <sdottaka@sourceforge.net>
Wed, 5 Nov 2014 05:45:52 +0000 (14:45 +0900)
committersdottaka <sdottaka@sourceforge.net>
Wed, 5 Nov 2014 05:45:52 +0000 (14:45 +0900)
(Move the global variable 'TransformationCategories' in FileTransform.* to Plugins.*)

--HG--
branch : stable

Src/FileTransform.cpp
Src/FileTransform.h
Src/Plugins.cpp
Src/Plugins.h

index c8baba8..5ce2482 100644 (file)
@@ -41,22 +41,6 @@ using Poco::Exception;
 int g_bUnpackerMode = PLUGIN_MANUAL;
 int g_bPredifferMode = PLUGIN_MANUAL;
 
-/**
- * @brief Category of transformation : define the transformation events
- *
- * @note USER categories are calls to scriptlets, or VB ActiveX DLL, or VC COM DLL
- * Use text definition : if you add one, nothing to do ; 
- * if you change one, you just have change the dll/scripts for that event
- */
-const wchar_t *TransformationCategories[] = 
-{
-       L"BUFFER_PREDIFF",
-       L"FILE_PREDIFF",
-       L"EDITOR_SCRIPT",
-       L"BUFFER_PACK_UNPACK",
-       L"FILE_PACK_UNPACK",
-       NULL,           // last empty : necessary
-};
 
 
 
index 2b53e49..ccf9a24 100644 (file)
@@ -31,7 +31,6 @@
 
 #include <vector>
 #include "UnicodeString.h"
-#include "unicoder.h"
 #include "resource.h"
 #include "MergeApp.h"
 
@@ -56,15 +55,6 @@ extern int g_bPredifferMode;
 
 
 /**
- * @brief List of transformation categories (events)
- *
- * @note If you add some event, you have to complete this array in FileTransform.cpp
- */
-extern const wchar_t *TransformationCategories[];
-
-
-
-/**
  * @brief Plugin information for a given file
  *
  * @note Can be be passed/copied between threads
index 218ff6d..0f388f6 100644 (file)
@@ -38,7 +38,7 @@
 #include <Poco/RegularExpression.h>
 #include <windows.h>
 #include "MergeApp.h"
-#include "FileTransform.h"
+#include "unicoder.h"
 #include "FileFilterMgr.h"
 #include "lwdisp.h"
 #include "resource.h"
@@ -53,6 +53,23 @@ using Poco::RegularExpression;
 using Poco::FastMutex;
 using Poco::ScopedLock;
 
+/**
+ * @brief Category of transformation : define the transformation events
+ *
+ * @note USER categories are calls to scriptlets, or VB ActiveX DLL, or VC COM DLL
+ * Use text definition : if you add one, nothing to do ; 
+ * if you change one, you just have change the dll/scripts for that event
+ */
+const wchar_t *TransformationCategories[] = 
+{
+       L"BUFFER_PREDIFF",
+       L"FILE_PREDIFF",
+       L"EDITOR_SCRIPT",
+       L"BUFFER_PACK_UNPACK",
+       L"FILE_PACK_UNPACK",
+       NULL,           // last empty : necessary
+};
+
 static vector<String> theScriptletList;
 /// Need to lock the *.sct so the user can't delete them
 static vector<HANDLE> theScriptletHandleList;
@@ -1208,7 +1225,7 @@ bool InvokeUnpackFile(const String& fileSource, const String& fileDest, int & nC
        // argument transformed text 
        VARIANT vbstrDst;
        vbstrDst.vt = VT_BSTR;
-       vbstrDst.bstrVal = SysAllocString(ucr::toUTF16(fileDest).c_str());
+       vbstrDst.bstrVal = SysAllocString(ucr::toUTF16(dest).c_str());
        // argument subcode by reference
        VARIANT vpiSubcode;
        vpiSubcode.vt = VT_BYREF | VT_I4;
@@ -1225,8 +1242,8 @@ bool InvokeUnpackFile(const String& fileSource, const String& fileDest, int & nC
 
        // invoke method by name, reverse order for arguments
        // VARIANT_BOOL UnpackFile(BSTR fileSrc, BSTR fileDst, VARIANT_BOOL * bChanged, INT * bSubcode)
-       HRESULT h = ::safeInvokeW(piScript,     &vboolHandled, L"UnpackFile", opFxn[4], 
-                            vpiSubcode, vpboolChanged, vbstrDst, vbstrSrc);
+       HRESULT h = ::safeInvokeW(piScript,     &vboolHandled, method, opFxn[4], 
+                                 vpiSubcode, vpboolChanged, vbstrDst, vbstrSrc);
        bool bSuccess = ! FAILED(h) && vboolHandled.boolVal;
        if (bSuccess && changed)
                nChanged ++;
@@ -1237,16 +1254,16 @@ bool InvokeUnpackFile(const String& fileSource, const String& fileDest, int & nC
        return  (bSuccess);
 }
 
-bool InvokePackFile(const String& fileSource, const String& fileDest, int & nChanged, IDispatch *piScript, int subCode)
+static bool pack(const wchar_t *method, const String& source, const String& dest, int & nChanged, IDispatch *piScript, int & subCode)
 {
        // argument text  
        VARIANT vbstrSrc;
        vbstrSrc.vt = VT_BSTR;
-       vbstrSrc.bstrVal = SysAllocString(ucr::toUTF16(fileSource).c_str());
+       vbstrSrc.bstrVal = SysAllocString(ucr::toUTF16(source).c_str());
        // argument transformed text 
        VARIANT vbstrDst;
        vbstrDst.vt = VT_BSTR;
-       vbstrDst.bstrVal = SysAllocString(ucr::toUTF16(fileDest).c_str());
+       vbstrDst.bstrVal = SysAllocString(ucr::toUTF16(dest).c_str());
        // argument subcode
        VARIANT viSubcode;
        viSubcode.vt = VT_I4;
@@ -1263,8 +1280,8 @@ bool InvokePackFile(const String& fileSource, const String& fileDest, int & nCha
 
        // invoke method by name, reverse order for arguments
        // VARIANT_BOOL PackFile(BSTR fileSrc, BSTR fileDst, VARIANT_BOOL * bChanged, INT bSubcode)
-       HRESULT h = ::safeInvokeW(piScript,     &vboolHandled, L"PackFile", opFxn[4], 
-                            viSubcode, vpboolChanged, vbstrDst, vbstrSrc);
+       HRESULT h = ::safeInvokeW(piScript,     &vboolHandled, method, opFxn[4], 
+                                 viSubcode, vpboolChanged, vbstrDst, vbstrSrc);
        bool bSuccess = ! FAILED(h) && vboolHandled.boolVal;
        if (bSuccess && changed)
                nChanged ++;
@@ -1275,6 +1292,26 @@ bool InvokePackFile(const String& fileSource, const String& fileDest, int & nCha
        return  (bSuccess);
 }
 
+bool InvokeUnpackFile(const String& fileSource, const String& fileDest, int & nChanged, IDispatch *piScript, int & subCode)
+{
+       return unpack(L"UnpackFile", fileSource, fileDest, nChanged, piScript, subCode);
+}
+
+bool InvokePackFile(const String& fileSource, const String& fileDest, int & nChanged, IDispatch *piScript, int subCode)
+{
+       return pack(L"PackFile", fileSource, fileDest, nChanged, piScript, subCode);
+}
+
+bool InvokeUnpackFolder(const String& fileSource, const String& folderDest, int & nChanged, IDispatch *piScript, int & subCode)
+{
+       return unpack(L"UnpackFolder", fileSource, folderDest, nChanged, piScript, subCode);
+}
+
+bool InvokePackFolder(const String& folderSource, const String& fileDest, int & nChanged, IDispatch *piScript, int subCode)
+{
+       return pack(L"PackFolder", folderSource, fileDest, nChanged, piScript, subCode);
+}
+
 bool InvokePrediffFile(const String& fileSource, const String& fileDest, int & nChanged, IDispatch *piScript)
 {
        // argument text  
index bff0bc5..b531d96 100644 (file)
 struct FileFilterElement;
 typedef boost::shared_ptr<FileFilterElement> FileFilterElementPtr;
 
+/**
+ * @brief List of transformation categories (events)
+ *
+ * @note If you add some event, you have to complete this array in FileTransform.cpp
+ */
+extern const wchar_t *TransformationCategories[];
+
 /** 
  * @brief Information structure for a plugin
  */