summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsje <sje@4f64403b-2f21-0410-a795-97e2b3489a10>2007-07-29 02:54:40 +0000
committersje <sje@4f64403b-2f21-0410-a795-97e2b3489a10>2007-07-29 02:54:40 +0000
commit8d2322e9200357df2fd873d385f99febad35effd (patch)
tree6f13ac4fe9999ca21192a054045c5b857a815e8b
parent3436bfa6059138bdb2007ae0a97a7d9d313e83c7 (diff)
set update url based on miranda's unicode status
allow ansi ver to read unicode dat file allow download of either version to replace either version (plugin name aliases) git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@305 4f64403b-2f21-0410-a795-97e2b3489a10
-rw-r--r--updater/extern.cpp27
-rw-r--r--updater/scan.cpp6
-rw-r--r--updater/updater.cpp49
-rw-r--r--updater/version.h9
4 files changed, 60 insertions, 31 deletions
diff --git a/updater/extern.cpp b/updater/extern.cpp
index 81254cf..eaaeb36 100644
--- a/updater/extern.cpp
+++ b/updater/extern.cpp
@@ -267,7 +267,28 @@ void MoveFiles(HANDLE hLogFile, TCHAR *src_folder, TCHAR *dst_folder, TCHAR *bac
RemoveDirectory(src_folder);
}
+bool ReadTLine(HANDLE hDatFile, TCHAR *line, int bsize, int &offset) {
+ unsigned long bytes_read;
+ BOOL bResult;
+ while((bResult = ReadFile(hDatFile, line + offset, sizeof(TCHAR), &bytes_read, 0)) && offset < bsize && bytes_read == sizeof(TCHAR) && line[offset] && (line[offset] != _T('\n') || (offset > 0 && line[offset - 1] != _T('\r')))) offset++;
+
+#ifndef _UNICODE
+ if(offset == 1 && line[1] == 0) {
+ wchar_t wline[MAX_PATH];
+ wline[0] = *(wchar_t *)line;
+
+ while((bResult = ReadFile(hDatFile, wline + offset, sizeof(wchar_t), &bytes_read, 0)) && offset < bsize && bytes_read == sizeof(wchar_t) && wline[offset] && (wline[offset] != L'\n' || (offset > 0 && wline[offset - 1] != L'\r'))) offset++;
+ if(offset > 0) wline[offset - 1] = 0; // cut off /r/n
+
+ WideCharToMultiByte(CP_ACP, 0, wline, -1, line, bsize, 0, 0);
+ }
+#endif
+ if(offset > 0) line[offset - 1] = 0; // cut off /r/n
+ return true;
+}
+
extern "C" void __declspec(dllexport) CALLBACK ExternalUpdate(HWND hwnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow) {
+ //MessageBox(0, _T("ExternalUpdate"), _T("Updater"), MB_OK);
HANDLE hDatFile = CreateFileA(lpszCmdLine, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
if(hDatFile == INVALID_HANDLE_VALUE) {
char msg[1024];
@@ -295,13 +316,11 @@ extern "C" void __declspec(dllexport) CALLBACK ExternalUpdate(HWND hwnd, HINSTAN
do {
offset = 0;
if(i == 2 || i == 3 || i == 6 || i == 7) {
- while((bResult = ReadFile(hDatFile, ans_line + offset, 1, &bytes_read, 0)) && offset < MAX_PATH && bytes_read == 1 && offset < MAX_PATH && ans_line[offset] && (ans_line[offset] != '\n' || (offset > 0 && ans_line[offset - 1] != '\r'))) offset++;
+ while((bResult = ReadFile(hDatFile, ans_line + offset, 1, &bytes_read, 0)) && offset < MAX_PATH && bytes_read == 1 && ans_line[offset] && (ans_line[offset] != '\n' || (offset > 0 && ans_line[offset - 1] != '\r'))) offset++;
if(offset > 0) ans_line[offset - 1] = 0; // cut off /r/n
//MessageBoxA(0, ans_line, "Read ANSI text line", MB_OK);
} else {
- while((bResult = ReadFile(hDatFile, line + offset, sizeof(TCHAR), &bytes_read, 0)) && offset < MAX_PATH && bytes_read == sizeof(TCHAR) && offset < MAX_PATH && line[offset] && (line[offset] != _T('\n') || (offset > 0 && line[offset - 1] != _T('\r')))) offset++;
- if(offset > 0) line[offset - 1] = 0; // cut off /r/n
- //MessageBox(0, line, _T("Read Unicode text line"), MB_OK);
+ ReadTLine(hDatFile, line, MAX_PATH, offset);
}
switch(i) {
case 0: _tcsncpy(mir_exe, line, MAX_PATH); break;
diff --git a/updater/scan.cpp b/updater/scan.cpp
index 5dda22a..8a9e15b 100644
--- a/updater/scan.cpp
+++ b/updater/scan.cpp
@@ -16,6 +16,10 @@ void InitAlternateShortNameMap() {
//alternate_shortname_map["Messaging Style Conversation"] = "nConvers++"; // will this conflict with other nConvers'?
alternate_shortname_map["MimQQ-libeva"] = "MirandaQQ (libeva Version)";
alternate_shortname_map["Icons Library Manager (Unicode)"] = "Icons library manager";
+
+ // grr
+ alternate_shortname_map["Updater"] = __PLUGIN_NAME;
+ alternate_shortname_map["Updater (Unicode)"] = __PLUGIN_NAME;
}
void ScanPlugins(FilenameMap *fn_map, UpdateList *update_list) {
@@ -59,7 +63,7 @@ void ScanPlugins(FilenameMap *fn_map, UpdateList *update_list) {
if((dll_info_func_ex && (pluginInfo = (PLUGININFO *)dll_info_func_ex(mirandaVersion))) || (dll_info_func && (pluginInfo = dll_info_func(mirandaVersion)))) {
// *** This is a dodgy and unfair hack...
- // In order to disable new plugins that may be unintentionally installed whith an update,
+ // In order to disable new plugins that may be unintentionally installed with an update,
// updater will check for the 'plugindisabled' setting for each dll. The problem is that
// this setting may not be there for running plugins - and isn't there for new ones. So,
// we'll disable anything new when the setting isn't found anyway - but we write the
diff --git a/updater/updater.cpp b/updater/updater.cpp
index c5d19a7..2dfc984 100644
--- a/updater/updater.cpp
+++ b/updater/updater.cpp
@@ -10,7 +10,7 @@ DWORD mainThreadId;
HANDLE mainThread;
bool is_idle = false;
-
+bool unicode_system;
//#define TESTING // defined here to reduce build time blowout caused by changing common.h
PLUGININFOEX pluginInfo={
@@ -145,38 +145,37 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) {
update.cpbVersion = strlen((char *)update.pbVersion);
-#ifdef _UNICODE
+ if(unicode_system) {
#ifdef REGISTER_AUTO
- update.szUpdateURL = UPDATER_AUTOREGISTER;
+ update.szUpdateURL = UPDATER_AUTOREGISTER;
#else //!REGISTER_AUTO
- update.szUpdateURL = MIM_DOWNLOAD_URL_PREFIX "2596";
- update.szVersionURL = MIM_VIEW_URL_PREFIX "2596";
- update.pbVersionPrefix = (BYTE *)"<span class=\"fileNameHeader\">Updater (Unicode) ";
- update.cpbVersionPrefix = strlen((char *)update.pbVersionPrefix);
+ update.szUpdateURL = MIM_DOWNLOAD_URL_PREFIX "2596";
+ update.szVersionURL = MIM_VIEW_URL_PREFIX "2596";
+ update.pbVersionPrefix = (BYTE *)"<span class=\"fileNameHeader\">Updater (Unicode) ";
+ update.cpbVersionPrefix = strlen((char *)update.pbVersionPrefix);
#endif //REGISTER_AUTO
- update.szBetaUpdateURL = BETA_HOST_URL_PREFIX "/updater_unicode.zip";
- update.szBetaVersionURL = BETA_HOST_URL_PREFIX "/ver_updater_unicode.html";
- update.pbBetaVersionPrefix = (BYTE *)"Updater (Unicode) version ";
- update.cpbBetaVersionPrefix = strlen((char *)update.pbBetaVersionPrefix);
-#else //!_UNICODE
+ update.szBetaUpdateURL = BETA_HOST_URL_PREFIX "/updater_unicode.zip";
+ update.szBetaVersionURL = BETA_HOST_URL_PREFIX "/ver_updater_unicode.html";
+ update.pbBetaVersionPrefix = (BYTE *)"Updater (Unicode) version ";
+ update.cpbBetaVersionPrefix = strlen((char *)update.pbBetaVersionPrefix);
+ } else {
#ifdef REGISTER_AUTO
- update.szUpdateURL = UPDATER_AUTOREGISTER;
+ update.szUpdateURL = UPDATER_AUTOREGISTER;
#else //!REGISTER_AUTO
- update.szUpdateURL = MIM_DOWNLOAD_URL_PREFIX "2254";
- update.szVersionURL = MIM_VIEW_URL_PREFIX "2254";
- update.pbVersionPrefix = (BYTE *)"<span class=\"fileNameHeader\">Updater ";
- update.cpbVersionPrefix = strlen((char *)update.pbVersionPrefix);
+ update.szUpdateURL = MIM_DOWNLOAD_URL_PREFIX "2254";
+ update.szVersionURL = MIM_VIEW_URL_PREFIX "2254";
+ update.pbVersionPrefix = (BYTE *)"<span class=\"fileNameHeader\">Updater ";
+ update.cpbVersionPrefix = strlen((char *)update.pbVersionPrefix);
#endif //REGISTER_AUTO
- update.szBetaUpdateURL = BETA_HOST_URL_PREFIX "/updater.zip";
- update.szBetaVersionURL = BETA_HOST_URL_PREFIX "/ver_updater.html";
- update.pbBetaVersionPrefix = (BYTE *)"Updater version ";
- update.cpbBetaVersionPrefix = strlen((char *)update.pbBetaVersionPrefix);
-#endif //_UNICODE
-
+ update.szBetaUpdateURL = BETA_HOST_URL_PREFIX "/updater.zip";
+ update.szBetaVersionURL = BETA_HOST_URL_PREFIX "/ver_updater.html";
+ update.pbBetaVersionPrefix = (BYTE *)"Updater version ";
+ update.cpbBetaVersionPrefix = strlen((char *)update.pbBetaVersionPrefix);
+ }
CallService(MS_UPDATE_REGISTER, 0, (WPARAM)&update);
#else // !REGISTER_BETA
@@ -223,7 +222,8 @@ extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
pluginLink = link;
char szVer[128];
- bool unicode_system = (CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM)sizeof(szVer), (LPARAM)szVer) == 0 && strstr(szVer, "Unicode"));
+ unicode_system = (CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM)sizeof(szVer), (LPARAM)szVer) == 0 && strstr(szVer, "Unicode"));
+ /*
#ifdef _UNICODE
if(!unicode_system) {
TCHAR fp[256], *fn;
@@ -243,6 +243,7 @@ extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
return 1;
}
#endif
+ */
mainThreadId = GetCurrentThreadId();
DuplicateHandle( GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &mainThread, THREAD_SET_CONTEXT, FALSE, 0 );
diff --git a/updater/version.h b/updater/version.h
index 6f23f4a..53bd680 100644
--- a/updater/version.h
+++ b/updater/version.h
@@ -4,8 +4,8 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 5
-#define __RELEASE_NUM 2
-#define __BUILD_NUM 4
+#define __RELEASE_NUM 3
+#define __BUILD_NUM 0
#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
#define __FILEVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM
@@ -18,7 +18,12 @@
#define __COPYRIGHT "© 2005,2006 Scott Ellis"
#define __AUTHORWEB "http://www.scottellis.com.au"
+#ifdef _UNICODE
+#define __PLUGIN_NAME "Updater (Unicode)"
+#else
#define __PLUGIN_NAME "Updater"
+#endif
+
#define __FILENAME "updater.dll"