Permalink
Browse files

Test for GPUP.EXE version is the same as the the plugin manager version

  • Loading branch information...
1 parent 37275c7 commit c6e3b74887c2be838a610b893cb77b0c5c989b55 @bruderstein committed Jan 1, 2012
Showing with 70 additions and 8 deletions.
  1. +4 −4 gpup/src/gpup.rc
  2. +3 −3 pluginManager/src/PluginManagerVersion.h
  3. +60 −0 pluginManager/src/Utility.cpp
  4. +3 −1 pluginManager/src/Utility.h
View
8 gpup/src/gpup.rc
@@ -96,8 +96,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,0,7,0
- PRODUCTVERSION 1,0,7,0
+ FILEVERSION 1,0,8,0
+ PRODUCTVERSION 1,0,8,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -114,12 +114,12 @@ BEGIN
BEGIN
VALUE "Comments", "A generic(ish) plugin updater, built initially for Notepad++"
VALUE "FileDescription", "gpup"
- VALUE "FileVersion", "1.0.7.0"
+ VALUE "FileVersion", "1.0.8.0"
VALUE "InternalName", "gpup"
VALUE "LegalCopyright", "Copyright (C) 2009-11 Dave Brotherstone"
VALUE "OriginalFilename", "gpup.exe"
VALUE "ProductName", " gpup"
- VALUE "ProductVersion", "1.0.7.0"
+ VALUE "ProductVersion", "1.0.8.0"
END
END
BLOCK "VarFileInfo"
View
6 pluginManager/src/PluginManagerVersion.h
@@ -1,9 +1,9 @@
#ifndef _PLUGINMANAGERVERSION_H
#define _PLUGINMANAGERVERSION_H
-#define PLUGINMANAGERVERSION_STRING "1.0.7.0"
-#define PLUGINMANAGERVERSION_RESOURCE 1,0,7,0
-#define PLUGINMANAGERVERSION_RESOURCE_STRING "1, 0, 7, 0"
+#define PLUGINMANAGERVERSION_STRING "1.0.8.0"
+#define PLUGINMANAGERVERSION_RESOURCE 1,0,8,0
+#define PLUGINMANAGERVERSION_RESOURCE_STRING "1, 0, 8, 0"
#define PLUGINMANAGERVERSION_RELEASEDATE "December 2011"
#endif
View
60 pluginManager/src/Utility.cpp
@@ -20,6 +20,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "precompiled_headers.h"
#include "Utility.h"
#include "PluginManager.h"
+#include "PluginVersion.h"
+#include "PluginManagerVersion.h"
BOOL Utility::removeDirectory(const TCHAR* directory)
{
@@ -77,6 +79,20 @@ void Utility::startGpup(HWND errorParent, const TCHAR *nppDir, const TCHAR *argu
return;
}
+ PluginVersion *gpupVersion = getFileVersion(gpupExe.c_str());
+
+ if ((*gpupVersion) != PluginVersion(PLUGINMANAGERVERSION_STRING))
+ {
+ ::MessageBox(errorParent, _T("The external plugin updater (gpup.exe) under ")
+ _T("the updater directory does not appear to be the correct version. ")
+ _T("It will most likely work, but you should reinstall the ")
+ _T("plugin manager at your next opportunity to ensure full ")
+ _T("functionality. We'll attempt to use the current version ")
+ _T("for this operation."),
+ _T("Plugin Manager GPUP.EXE Version"),
+ MB_OK | MB_ICONWARNING);
+ }
+ delete gpupVersion;
//gpupExe.insert(0, _T("\""));
//gpupExe.append(_T("\" "));
@@ -136,4 +152,48 @@ void Utility::startGpup(HWND errorParent, const TCHAR *nppDir, const TCHAR *argu
&startup, // STARTUPINFO
&procinfo); // PROCESS_INFORMATION
*/
+}
+
+
+PluginVersion* Utility::getFileVersion(const TCHAR* path)
+{
+ DWORD handle;
+ DWORD bufferSize = ::GetFileVersionInfoSize(path, &handle);
+ PluginVersion *version;
+
+ if (bufferSize <= 0)
+ return new PluginVersion();
+
+ unsigned char* buffer = new unsigned char[bufferSize];
+ ::GetFileVersionInfo(path, handle, bufferSize, buffer);
+
+ /*struct LANGANDCODEPAGE {
+ WORD wLanguage;
+ WORD wCodePage;
+ } *lpTranslate;*/
+
+ VS_FIXEDFILEINFO* lpFileInfo;
+
+ UINT cbFileInfo;
+
+ VerQueryValue(buffer,
+ _T("\\"),
+ (LPVOID*)&lpFileInfo,
+ &cbFileInfo);
+
+ if (cbFileInfo)
+ {
+ version = new PluginVersion((lpFileInfo->dwFileVersionMS & 0xFFFF0000) >> 16,
+ lpFileInfo->dwFileVersionMS & 0x0000FFFF,
+ (lpFileInfo->dwFileVersionLS & 0xFFFF0000) >> 16,
+ lpFileInfo->dwFileVersionLS & 0x0000FFFF);
+ }
+ else
+ {
+ version = new PluginVersion();
+ }
+
+ delete [] buffer;
+
+ return version;
}
View
4 pluginManager/src/Utility.h
@@ -17,12 +17,14 @@ 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+class PluginVersion;
class Utility
{
public:
static BOOL removeDirectory(const TCHAR* directory);
static void startGpup(const HWND errorParent, const TCHAR* nppDir, const TCHAR* arguments, bool needAdmin);
-
+ static PluginVersion* getFileVersion(const TCHAR* path);
+
};

0 comments on commit c6e3b74

Please sign in to comment.