diff options
Diffstat (limited to 'plugins/PluginUpdater')
-rw-r--r-- | plugins/PluginUpdater/src/Common.h | 6 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Minizip/ioapi.c | 2 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Minizip/unzip.c | 16 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Notifications.cpp | 18 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Options.cpp | 4 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Scanner.cpp | 67 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Utils.cpp | 4 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Version.h | 2 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/unzipfile.cpp | 12 |
9 files changed, 62 insertions, 69 deletions
diff --git a/plugins/PluginUpdater/src/Common.h b/plugins/PluginUpdater/src/Common.h index 9efcd8b875..3d79a36f33 100644 --- a/plugins/PluginUpdater/src/Common.h +++ b/plugins/PluginUpdater/src/Common.h @@ -78,10 +78,7 @@ struct FILEINFO {
TCHAR tszOldName[MAX_PATH], tszNewName[MAX_PATH];
FILEURL File;
- BOOL enabled, bDeleteOnly;
- BYTE FileType;
- int FileNum;
- BYTE Force;
+ BOOL bEnabled, bDeleteOnly;
};
typedef OBJLIST<FILEINFO> FILELIST;
@@ -139,7 +136,6 @@ int OnFoldersChanged(WPARAM, LPARAM); int OnPreShutdown(WPARAM, LPARAM);
int OptInit(WPARAM, LPARAM);
-void PrepareFileName(TCHAR *dest, size_t destSize, const TCHAR *ptszPath, const TCHAR *ptszFileName);
void BackupFile(TCHAR *ptszSrcFileName, TCHAR *ptszBackFileName);
void DoCheck(int iFlag);
diff --git a/plugins/PluginUpdater/src/Minizip/ioapi.c b/plugins/PluginUpdater/src/Minizip/ioapi.c index a6cd3f3ca8..4219ed1f24 100644 --- a/plugins/PluginUpdater/src/Minizip/ioapi.c +++ b/plugins/PluginUpdater/src/Minizip/ioapi.c @@ -199,7 +199,7 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T } ret = 0; - if(fseeko64((FILE *)stream, offset, fseek_origin) != 0) + if (fseeko64((FILE *)stream, offset, fseek_origin) != 0) ret = -1; return ret; diff --git a/plugins/PluginUpdater/src/Minizip/unzip.c b/plugins/PluginUpdater/src/Minizip/unzip.c index 44f9876160..59b5941576 100644 --- a/plugins/PluginUpdater/src/Minizip/unzip.c +++ b/plugins/PluginUpdater/src/Minizip/unzip.c @@ -753,7 +753,7 @@ local unzFile unzOpenInternal (const void *path, s=(unz64_s*)ALLOC(sizeof(unz64_s)); - if( s != NULL) + if ( s != NULL) { *s=us; unzGoToFirstFile((unzFile)s); @@ -1040,26 +1040,26 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file, { uLong uL; - if(file_info.uncompressed_size == (ZPOS64_T)(unsigned long)-1) + if (file_info.uncompressed_size == (ZPOS64_T)(unsigned long)-1) { if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK) err=UNZ_ERRNO; } - if(file_info.compressed_size == (ZPOS64_T)(unsigned long)-1) + if (file_info.compressed_size == (ZPOS64_T)(unsigned long)-1) { if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK) err=UNZ_ERRNO; } - if(file_info_internal.offset_curfile == (ZPOS64_T)(unsigned long)-1) + if (file_info_internal.offset_curfile == (ZPOS64_T)(unsigned long)-1) { /* Relative Header offset */ if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK) err=UNZ_ERRNO; } - if(file_info.disk_num_start == (unsigned long)-1) + if (file_info.disk_num_start == (unsigned long)-1) { /* Disk Start Number */ if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) @@ -1623,7 +1623,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method, s->pfile_in_zip_read->byte_before_the_zipfile, SEEK_SET)!=0) return UNZ_INTERNALERROR; - if(ZREAD64(s->z_filefunc, s->filestream,source, 12)<12) + if (ZREAD64(s->z_filefunc, s->filestream,source, 12)<12) return UNZ_INTERNALERROR; for (i = 0; i<12; i++) @@ -1741,10 +1741,10 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len) # ifndef NOUNCRYPT - if(s->encrypted) + if (s->encrypted) { uInt i; - for(i=0;i<uReadThis;i++) + for (i=0;i<uReadThis;i++) pfile_in_zip_read_info->read_buffer[i] = zdecode(s->keys,s->pcrc_32_tab, pfile_in_zip_read_info->read_buffer[i]); diff --git a/plugins/PluginUpdater/src/Notifications.cpp b/plugins/PluginUpdater/src/Notifications.cpp index 364f2f0af7..e9f26d170f 100644 --- a/plugins/PluginUpdater/src/Notifications.cpp +++ b/plugins/PluginUpdater/src/Notifications.cpp @@ -216,7 +216,7 @@ void SelectAll(HWND hDlg, bool bEnable) for (int i=0; i < todo.getCount(); i++) {
ListView_SetCheckState(hwndList, i, bEnable);
- todo[i].enabled = bEnable;
+ todo[i].bEnabled = bEnable;
}
}
@@ -240,11 +240,11 @@ static void ApplyUpdates(void *param) for (int i=0; i < todo.getCount(); ++i) {
ListView_EnsureVisible(hwndList, i, FALSE);
- if ( !todo[i].enabled ) {
+ if ( !todo[i].bEnabled) {
SetStringText(hwndList, i, TranslateT("Skipped."));
continue;
}
- if ( todo[i].bDeleteOnly) {
+ if (todo[i].bDeleteOnly) {
SetStringText(hwndList, i, TranslateT("Will be deleted!"));
continue;
}
@@ -279,7 +279,7 @@ static void ApplyUpdates(void *param) TCHAR *tszMirandaPath = Utils_ReplaceVarsT(_T("%miranda_path%"));
for (int i = 0; i < todo.getCount(); i++) {
- if ( !todo[i].enabled)
+ if ( !todo[i].bEnabled)
continue;
TCHAR tszBackFile[MAX_PATH];
@@ -365,7 +365,7 @@ BOOL IsRunAsAdmin() goto Cleanup;
}
- // Determine whether the SID of administrators group is enabled in
+ // Determine whether the SID of administrators group is bEnabled in
// the primary access token of the process.
if (!CheckTokenMembership(NULL, pAdministratorsGroup, &fIsRunAsAdmin))
{
@@ -545,7 +545,7 @@ INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam // remember whether the user has decided not to update this component with this particular new version
ListView_SetCheckState(hwndList, lvI.iItem, true);
- todo[i].enabled = true;
+ todo[i].bEnabled = true;
}
HWND hwOk = GetDlgItem(hDlg, IDOK);
EnableWindow(hwOk, true);
@@ -574,11 +574,11 @@ INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam OBJLIST<FILEINFO> &todo = *(OBJLIST<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
if ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK) {
- todo[lvI.iItem].enabled = ListView_GetCheckState(hwndList, nmlv->iItem);
+ todo[lvI.iItem].bEnabled = ListView_GetCheckState(hwndList, nmlv->iItem);
bool enableOk = false;
- for(int i=0; i < todo.getCount(); ++i) {
- if(todo[i].enabled) {
+ for (int i=0; i < todo.getCount(); ++i) {
+ if (todo[i].bEnabled) {
enableOk = true;
break;
}
diff --git a/plugins/PluginUpdater/src/Options.cpp b/plugins/PluginUpdater/src/Options.cpp index 91fbfa80a5..3d24fb72c8 100644 --- a/plugins/PluginUpdater/src/Options.cpp +++ b/plugins/PluginUpdater/src/Options.cpp @@ -243,7 +243,7 @@ INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) {
WORD idCtrl = LOWORD(wParam), wNotifyCode = HIWORD(wParam);
if (wNotifyCode == CPN_COLOURCHANGED) {
- if(idCtrl > 40070) {
+ if (idCtrl > 40070) {
//It's a color picker change. idCtrl is the control id.
COLORREF color = SendDlgItemMessage(hdlg, idCtrl, CPM_GETCOLOUR, 0, 0);
int ctlID = idCtrl;
@@ -259,7 +259,7 @@ INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) if (wNotifyCode == CBN_SELCHANGE) {
if (idCtrl == IDC_LC)
PopupOptions.LeftClickAction = (BYTE)SendDlgItemMessage(hdlg, IDC_LC, CB_GETCURSEL, 0, 0);
- else if(idCtrl == IDC_RC)
+ else if (idCtrl == IDC_RC)
PopupOptions.RightClickAction = (BYTE)SendDlgItemMessage(hdlg, IDC_RC, CB_GETCURSEL, 0, 0);
SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
diff --git a/plugins/PluginUpdater/src/Scanner.cpp b/plugins/PluginUpdater/src/Scanner.cpp index 25e6ea388a..65c38b34a3 100644 --- a/plugins/PluginUpdater/src/Scanner.cpp +++ b/plugins/PluginUpdater/src/Scanner.cpp @@ -35,17 +35,33 @@ static bool Exists(LPCTSTR strName) struct ServListEntry
{
+ ServListEntry(const char* _name, const char* _hash) :
+ m_name( mir_a2t(_name)),
+ m_bNeedFree(true)
+ {
+ strncpy(m_szHash, _hash, sizeof(m_szHash));
+ }
+
+ ServListEntry(TCHAR* _name) :
+ m_name(_name),
+ m_bNeedFree(false)
+ {
+ }
+
~ServListEntry()
- { mir_free(m_name);
+ {
+ if (m_bNeedFree)
+ mir_free(m_name);
}
- TCHAR *m_name, *m_searchName;
+ TCHAR *m_name;
char m_szHash[32+1];
+ bool m_bNeedFree;
};
static int CompareHashes(const ServListEntry *p1, const ServListEntry *p2)
{
- return _tcscmp(p1->m_searchName, p2->m_searchName);
+ return _tcsicmp(p1->m_name, p2->m_name);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -128,15 +144,10 @@ static void ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, int level, cons // this file is not marked for deletion
if (tszNewName[0]) {
- // parse a relative name and extract a key for hashtable lookup
- TCHAR *ptszName = _tcschr(tszNewName, '\\');
- ptszName = (ptszName != NULL) ? ptszName+1 : tszNewName;
- _tcscpy(key, ptszName);
- _tcslwr(key);
- ServListEntry tmp = {NULL, key};
+ ServListEntry tmp(tszNewName);
ServListEntry *item = hashes.find(&tmp);
if (item == NULL) {
- TCHAR *p = _tcschr(key, '.');
+ TCHAR *p = _tcsrchr(tszNewName, '.');
if (p[-1] != 'w')
continue;
@@ -145,13 +156,9 @@ static void ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, int level, cons if ((item = hashes.find(&tmp)) == NULL)
continue;
- strdel(ptszName+iPos, 1);
+ strdel(tszNewName+iPos, 1);
}
- PrepareFileName(key, SIZEOF(key), NULL, item->m_name);
- if ( _tcsicmp(tszNewName, key)) // skip files with the same names from another folders
- continue;
-
ptszUrl = item->m_name;
char szMyHash[33];
@@ -174,19 +181,20 @@ static void ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, int level, cons }
else {
FileInfo->bDeleteOnly = FALSE;
- PrepareFileName(FileInfo->tszNewName, SIZEOF(FileInfo->tszNewName), NULL, ptszUrl);
+ _tcsncpy(FileInfo->tszNewName, ptszUrl, SIZEOF(FileInfo->tszNewName));
}
_tcscpy(tszBuf, ptszUrl);
TCHAR *p = _tcsrchr(tszBuf, '.');
if (p) *p = 0;
- p = _tcsrchr(tszBuf, '/');
-
- mir_sntprintf(FileInfo->File.tszDiskPath, SIZEOF(FileInfo->File.tszDiskPath), _T("%s\\Temp\\%s.zip"), tszRoot, (p) ? p+1 : tszBuf);
- mir_sntprintf(FileInfo->File.tszDownloadURL, SIZEOF(FileInfo->File.tszDownloadURL), _T("%s/%s"), tszBaseUrl, ptszUrl);
- if ((pExt = _tcsrchr(FileInfo->File.tszDownloadURL, '.')) != NULL)
- _tcscpy(pExt, _T(".zip"));
-
+ p = _tcsrchr(tszBuf, '\\');
+ p = (p) ? p+1 : tszBuf;
+ _tcslwr(p);
+
+ mir_sntprintf(FileInfo->File.tszDiskPath, SIZEOF(FileInfo->File.tszDiskPath), _T("%s\\Temp\\%s.zip"), tszRoot, p);
+ mir_sntprintf(FileInfo->File.tszDownloadURL, SIZEOF(FileInfo->File.tszDownloadURL), _T("%s/%s.zip"), tszBaseUrl, tszBuf);
+ for (p = _tcschr(FileInfo->File.tszDownloadURL, '\\'); p != 0; p = _tcschr(p, '\\'))
+ *p++ = '/';
UpdateFiles->insert(FileInfo);
} // end compare versions
}
@@ -262,19 +270,8 @@ static void CheckUpdates(void *) if ( !opts.bUpdateIcons && !_strnicmp(str, "icons\\", 6))
continue;
- ServListEntry *newItem = new ServListEntry;
_strlwr(p);
- strncpy(newItem->m_szHash, p, sizeof(newItem->m_szHash));
-
- for (p = strchr(str, '\\'); p != NULL; p = strchr(p+1, '\\'))
- *p = '/';
-
- newItem->m_name = mir_a2t(str);
-
- TCHAR *szName = _tcsrchr(newItem->m_name, '/');
- newItem->m_searchName = (szName == NULL) ? newItem->m_name : szName+1;
- _tcslwr(newItem->m_searchName);
- hashes.insert(newItem);
+ hashes.insert(new ServListEntry(str, p));
}
fclose(fp);
DeleteFile(tszTmpIni);
diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp index da09a0846e..c94730da3b 100644 --- a/plugins/PluginUpdater/src/Utils.cpp +++ b/plugins/PluginUpdater/src/Utils.cpp @@ -188,7 +188,7 @@ BOOL AllowUpdateOnStartup() time_t now = time(NULL);
time_t was = DBGetContactSettingDword(NULL, MODNAME, "LastUpdate", 0);
- if((now - was) < 86400)
+ if ((now - was) < 86400)
return FALSE;
}
return TRUE;
@@ -205,7 +205,7 @@ LONG PeriodToMilliseconds(const int period, BYTE& periodMeasure) default:
// hour
- if(periodMeasure != 0)
+ if (periodMeasure != 0)
periodMeasure = 0;
result *= 60 * 60;
break;
diff --git a/plugins/PluginUpdater/src/Version.h b/plugins/PluginUpdater/src/Version.h index 344de91022..e477fe0877 100644 --- a/plugins/PluginUpdater/src/Version.h +++ b/plugins/PluginUpdater/src/Version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
#define __RELEASE_NUM 0
-#define __BUILD_NUM 1
+#define __BUILD_NUM 2
#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
#define __FILEVERSION_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM
diff --git a/plugins/PluginUpdater/src/unzipfile.cpp b/plugins/PluginUpdater/src/unzipfile.cpp index c5f39e1451..b2b621d37a 100644 --- a/plugins/PluginUpdater/src/unzipfile.cpp +++ b/plugins/PluginUpdater/src/unzipfile.cpp @@ -26,12 +26,9 @@ extern "C" void fill_fopen64_filefunc(zlib_filefunc64_def *pzlib_filefunc_def);
}
-void PrepareFileName(TCHAR *dest, size_t destSize, const TCHAR *ptszPath, const TCHAR *ptszFileName)
+static void PrepareFileName(TCHAR *dest, size_t destSize, const TCHAR *ptszPath, const TCHAR *ptszFileName)
{
- if (ptszPath)
- mir_sntprintf(dest, destSize, _T("%s\\%s"), ptszPath, ptszFileName);
- else
- mir_sntprintf(dest, destSize, _T("%s"), ptszFileName);
+ mir_sntprintf(dest, destSize, _T("%s\\%s"), ptszPath, ptszFileName);
for (TCHAR *p = dest; *p; ++p)
if (*p == '/')
@@ -42,7 +39,10 @@ void BackupFile(TCHAR *ptszSrcFileName, TCHAR *ptszBackFileName) {
CreatePathToFileT(ptszBackFileName);
DeleteFile(ptszBackFileName);
- MoveFile(ptszSrcFileName, ptszBackFileName);
+ if ( MoveFile(ptszSrcFileName, ptszBackFileName) == 0) { // use copy on error
+ CopyFile(ptszSrcFileName, ptszBackFileName, FALSE);
+ DeleteFile(ptszSrcFileName);
+ }
}
bool extractCurrentFile(unzFile uf, TCHAR *ptszDestPath, TCHAR *ptszBackPath)
|