diff options
author | (no author) <(no author)@4f64403b-2f21-0410-a795-97e2b3489a10> | 2010-05-21 02:14:42 +0000 |
---|---|---|
committer | (no author) <(no author)@4f64403b-2f21-0410-a795-97e2b3489a10> | 2010-05-21 02:14:42 +0000 |
commit | bc008612f7e63b5528dc9eba2467515b921b03bb (patch) | |
tree | 83a2109a3d41b92a4a20fdfc3b07f6f6ff0782ae | |
parent | dcc550972476817bd4d706700160c49dad145b54 (diff) |
Fixed restart with folders plugin
git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@519 4f64403b-2f21-0410-a795-97e2b3489a10
-rw-r--r-- | updater/scan.cpp | 148 | ||||
-rw-r--r-- | updater/services.cpp | 2 | ||||
-rw-r--r-- | updater/version.h | 2 | ||||
-rw-r--r-- | updater/xmldata.cpp | 2 |
4 files changed, 53 insertions, 101 deletions
diff --git a/updater/scan.cpp b/updater/scan.cpp index 04cff9e..ff86172 100644 --- a/updater/scan.cpp +++ b/updater/scan.cpp @@ -35,6 +35,12 @@ const char* findAlternateShortName(const char* name) return NULL;
}
+bool valDllName(TCHAR* name)
+{
+ TCHAR *p = _tcsrchr(name, '.');
+ return p && _tcsicmp(p, _T(".dll")) == 0;
+}
+
void ScanPlugins(FilenameMap *fn_map, UpdateList *update_list)
{
if (!XMLDataAvailable(MC_PLUGINS)) return;
@@ -46,7 +52,6 @@ void ScanPlugins(FilenameMap *fn_map, UpdateList *update_list) Miranda_Plugin_Info_Ex dll_info_func_ex;
DWORD mirandaVersion = (DWORD)CallService(MS_SYSTEM_GETVERSION, 0, 0);
PLUGININFO *pluginInfo;
- HMODULE hModule;
GetModuleFileName(0, mir_exe, MAX_PATH);
@@ -67,13 +72,20 @@ void ScanPlugins(FilenameMap *fn_map, UpdateList *update_list) WIN32_FIND_DATA findData;
HANDLE hFileSearch = FindFirstFile(plugins_folder, &findData);
- if(hFileSearch != INVALID_HANDLE_VALUE)
+ if (hFileSearch != INVALID_HANDLE_VALUE)
{
do {
- _tcscpy(dll_name, findData.cFileName);
- hModule = GetModuleHandle(dll_path);
- bool notLoaded = hModule == NULL;
- if (notLoaded) hModule = LoadLibrary(dll_path);
+ HMODULE hModule = NULL;
+ bool notLoaded = false;
+ if (valDllName(findData.cFileName))
+ {
+ _tcscpy(dll_name, findData.cFileName);
+ if (hModule = GetModuleHandle(dll_path))
+ {
+ hModule = LoadLibrary(dll_path);
+ notLoaded = true;
+ }
+ }
if (hModule)
{
dll_info_func = (Miranda_Plugin_Info)GetProcAddress(hModule, "MirandaPluginInfo");
@@ -229,35 +241,31 @@ void ScanLangpacks(FilenameMap *fn_map, UpdateList *update_list) }
}
-
-
-bool RearrangeDlls(char *shortName, StrList &filenames)
+bool RearrangeDllsWorker(char *shortName, StrList &filenames, TCHAR *basedir)
{
bool dll_enabled = false;
-
- TCHAR file_path[MAX_PATH], updates_folder[MAX_PATH], new_filename[MAX_PATH];
- TCHAR *dll_name;
BYTE disabled_val;
+ TCHAR file_path[MAX_PATH];
+
Miranda_Plugin_Info dll_info_func;
Miranda_Plugin_Info_Ex dll_info_func_ex;
DWORD mirandaVersion = (DWORD)CallService(MS_SYSTEM_GETVERSION, 0, 0);
PLUGININFO *pluginInfo;
HMODULE hModule;
- mir_sntprintf(file_path, SIZEOF(file_path), _T("%s\\"), options.temp_folder);
- // set dll_name to point into the file_path string, at the point where we can write the plugin name
- // to end up with the full dll path
- dll_name = file_path + _tcslen(file_path);
-
// add filemask
- mir_sntprintf(updates_folder, SIZEOF(updates_folder), _T("%s\\*.dll"), options.temp_folder);
+ mir_sntprintf(file_path, SIZEOF(file_path), _T("%s\\*.dll"), basedir);
WIN32_FIND_DATA findData;
- HANDLE hFileSearch = FindFirstFile(updates_folder, &findData);
- if(hFileSearch != INVALID_HANDLE_VALUE) {
- do {
- if(hModule = LoadLibrary(file_path)) {
+ HANDLE hFileSearch = FindFirstFile(file_path, &findData);
+ if (hFileSearch != INVALID_HANDLE_VALUE)
+ {
+ do
+ {
+ mir_sntprintf(file_path, SIZEOF(file_path), _T("%s\\%s"), basedir, findData.cFileName);
+ if (valDllName(findData.cFileName) && (hModule = LoadLibrary(file_path)))
+ {
dll_info_func = (Miranda_Plugin_Info)GetProcAddress(hModule, "MirandaPluginInfo");
dll_info_func_ex = (Miranda_Plugin_Info_Ex)GetProcAddress(hModule, "MirandaPluginInfoEx");
if((dll_info_func_ex && (pluginInfo = (PLUGININFO *)dll_info_func_ex(mirandaVersion))) || (dll_info_func && (pluginInfo = dll_info_func(mirandaVersion))))
@@ -271,14 +279,15 @@ bool RearrangeDlls(char *shortName, StrList &filenames) TCHAR* newname = NULL;
for (int j = 0; j < filenames.getCount(); j++)
{
+ TCHAR new_filename[MAX_PATH];
TCHAR* fileName = filenames[j];
- mir_sntprintf(new_filename, SIZEOF(new_filename), _T("%s\\%s"), options.temp_folder, fileName);
+ mir_sntprintf(new_filename, SIZEOF(new_filename), _T("%s\\%s"), basedir, fileName);
// disable any new plugins (i.e. not installed before) that somehome got into the
// dowloaded archives (e.g. loadavatars comes with loadavatarsw - installing both is not good!)
char *temp_str = mir_t2a(fileName);
disabled_val = DBGetContactSettingByte(0, "PluginDisable", temp_str, 255);
- if(disabled_val == 255) { // assume this means setting not in db (should be 1 or 0)
+ if (disabled_val == 255) { // assume this means setting not in db (should be 1 or 0)
DBWriteContactSettingByte(0, "PluginDisable", temp_str, 1);
disabled_val = 1;
}
@@ -286,98 +295,41 @@ bool RearrangeDlls(char *shortName, StrList &filenames) dll_enabled |= (disabled_val == 0);
- //MessageBox(0, new_filename, "New Filename", MB_OK);
- if (!moved) {
+ if (!moved)
+ {
if (_tcsicmp(findData.cFileName, fileName))
MoveFile(file_path, new_filename);
mir_free(newname); newname = mir_tstrdup(new_filename);
moved = true;
- } else {
- //char msg[2048];
- //sprintf(msg, "Copying %s to %s", newname.c_str(), new_filename);
- //MessageBox(0, msg, "msg", MB_OK);
+ } else
CopyFile(newname, new_filename, FALSE);
- }
}
mir_free(newname);
FreeLibrary(hModule);
break;
}
- } //else
- //MessageBox(0, _T("Library does not contain Miranda PluginInfo function"), findData.cFileName, MB_OK);
+ }
FreeLibrary(hModule);
- } //else
- //MessageBox(0, _T("File not loadable as library"), findData.cFileName, MB_OK);
- } while(FindNextFile(hFileSearch, &findData));
+ }
+ }
+ while(FindNextFile(hFileSearch, &findData));
FindClose(hFileSearch);
}
+ return dll_enabled;
+}
- // do exactly the same thing again, for the updates/plugins folder... :(
-
- _tcscpy(file_path, options.temp_folder);
- _tcscat(file_path, _T("\\Plugins\\"));
- dll_name = file_path + _tcslen(file_path);
-
- // add filemask
- _tcscpy(updates_folder, options.temp_folder);
- _tcscat(updates_folder, _T("\\Plugins\\*.dll"));
-
- hFileSearch = FindFirstFile(updates_folder, &findData);
- if(hFileSearch != INVALID_HANDLE_VALUE) {
- do {
- _tcscpy(dll_name, findData.cFileName);
- _tcslwr(findData.cFileName);
-
- if(hModule = LoadLibrary(file_path)) {
- dll_info_func = (Miranda_Plugin_Info)GetProcAddress(hModule, "MirandaPluginInfo");
- dll_info_func_ex = (Miranda_Plugin_Info_Ex)GetProcAddress(hModule, "MirandaPluginInfoEx");
- if((dll_info_func_ex && (pluginInfo = (PLUGININFO *)dll_info_func_ex(mirandaVersion))) || (dll_info_func && (pluginInfo = dll_info_func(mirandaVersion))))
- {
- const char* alternateName = findAlternateShortName(pluginInfo->shortName);
- if (alternateName == NULL) alternateName = pluginInfo->shortName;
-
- if (_stricmp(alternateName, shortName) == 0)
- {
- bool moved = false;
- TCHAR* newname = NULL;
- for (int j = 0; j < filenames.getCount(); j++)
- {
- TCHAR *fileName = filenames[j];
- mir_sntprintf(new_filename, SIZEOF(new_filename), _T("%s\\Plugins\\%s"), options.temp_folder, fileName);
- // disable any new plugins (i.e. not installed before) that somehome got into the
- // dowloaded archives (e.g. loadavatars comes with loadavatarsw - installing both is not good!)
- char *temp_str = mir_t2a(fileName);
- disabled_val = DBGetContactSettingByte(0, "PluginDisable", temp_str, 255);
- if(disabled_val == 255) { // assume this means setting not in db (should be 1 or 0)
- DBWriteContactSettingByte(0, "PluginDisable", temp_str, 1);
- disabled_val = 1;
- }
- mir_free(temp_str);
+bool RearrangeDlls(char *shortName, StrList &filenames)
+{
+ bool dll_enabled = false;
- dll_enabled |= (disabled_val == 0);
-
- if(!moved) {
- if (_tcsicmp(findData.cFileName, fileName) != 0)
- MoveFile(file_path, new_filename);
- mir_free(newname); newname = mir_tstrdup(new_filename);
- moved = true;
- } else
- CopyFile(newname, new_filename, FALSE);
- }
- mir_free(newname);
- FreeLibrary(hModule);
- break;
- }
- }
- FreeLibrary(hModule);
- }
- } while(FindNextFile(hFileSearch, &findData));
- FindClose(hFileSearch);
- }
+ TCHAR dir[MAX_PATH];
+ mir_sntprintf(dir, SIZEOF(dir), _T("%s\\Plugins"), options.temp_folder);
- return dll_enabled;
+ return
+ RearrangeDllsWorker(shortName, filenames, options.temp_folder) ||
+ RearrangeDllsWorker(shortName, filenames, dir);
}
bool RearrangeLangpacks(char *shortName, StrList &filenames)
diff --git a/updater/services.cpp b/updater/services.cpp index 62e88b9..6ce12d6 100644 --- a/updater/services.cpp +++ b/updater/services.cpp @@ -309,7 +309,7 @@ void CheckForUpdatesWorker(void *param) { }
bool dll_enabled_or_langpack = DownloadUpdates(todo, &fn_map, confirm ? false : options.auto_dll_only);
- if(todo.getCount() && !no_install) {
+ if (todo.getCount() && !no_install) {
if(!conf_all || DialogBox(hInst, MAKEINTRESOURCE(IDD_CONFIRMCOMPONENTS), GetDesktopWindow(), DlgProcConfirmComponents) == IDOK) {
if(!dll_enabled_or_langpack && restart) {
// we're not doing an 'update and shutdown', and we're not updating any active dlls...so just install
diff --git a/updater/version.h b/updater/version.h index 7faeeff..54f7e5e 100644 --- a/updater/version.h +++ b/updater/version.h @@ -5,7 +5,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 6
#define __RELEASE_NUM 0
-#define __BUILD_NUM 6
+#define __BUILD_NUM 7
#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
#define __FILEVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM
diff --git a/updater/xmldata.cpp b/updater/xmldata.cpp index 3a4677a..2e2e407 100644 --- a/updater/xmldata.cpp +++ b/updater/xmldata.cpp @@ -267,7 +267,7 @@ bool UpdateXMLData(const Category cat, const char *redirect_url /*= 0*/, int rec NETLIBHTTPREQUEST *resp = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser, (LPARAM)&req);
if(etag_hdr.szValue) free(etag_hdr.szValue);
- if(!resp) {
+ if (!resp) {
hNetlibHttp = NULL;
int err = GetLastError();
if(err) {
|