diff options
author | George Hazan <george.hazan@gmail.com> | 2014-07-02 15:18:50 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-07-02 15:18:50 +0000 |
commit | 5174b6de32477883b4efe1235643c9faa273521b (patch) | |
tree | 629bc2ebc0cdbebac343cafd14066d8b0253a6bb /plugins | |
parent | 547af691ad60fb3935075f033343bb870dfba464 (diff) |
finally wiping all obsolete stuff from 0.95
git-svn-id: http://svn.miranda-ng.org/main/trunk@9644 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Db3x_mmap/src/commonheaders.h | 2 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbcrypt.cpp | 105 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbheaders.cpp | 32 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbintf.cpp | 6 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbintf.h | 2 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/version.h | 4 |
6 files changed, 37 insertions, 114 deletions
diff --git a/plugins/Db3x_mmap/src/commonheaders.h b/plugins/Db3x_mmap/src/commonheaders.h index 01d0ce2eca..a82ea9dac6 100644 --- a/plugins/Db3x_mmap/src/commonheaders.h +++ b/plugins/Db3x_mmap/src/commonheaders.h @@ -50,7 +50,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern HINSTANCE g_hInst;
extern LIST<CDb3Mmap> g_Dbs;
-extern DBSignature dbSignatureU, dbSignatureE, dbSignatureIM, dbSignatureSA;
+extern DBSignature dbSignatureU, dbSignatureE, dbSignatureIM, dbSignatureSA, dbSignatureSD;
#ifdef __GNUC__
#define mir_i64(x) (x##LL)
diff --git a/plugins/Db3x_mmap/src/dbcrypt.cpp b/plugins/Db3x_mmap/src/dbcrypt.cpp index 48731212d7..dddbfd2641 100644 --- a/plugins/Db3x_mmap/src/dbcrypt.cpp +++ b/plugins/Db3x_mmap/src/dbcrypt.cpp @@ -23,114 +23,32 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "commonheaders.h"
-/////////////////////////////////////////////////////////////////////////////////////////
-
-//VERY VERY VERY BASIC ENCRYPTION FUNCTION
-
-static void Encrypt(char *msg, BOOL up)
-{
- int jump = (up) ? 5 : -5;
- for (int i = 0; msg[i]; i++)
- msg[i] = msg[i] + jump;
-}
-
-__forceinline void DecodeString(LPSTR buf)
-{
- Encrypt(buf, FALSE);
-}
-
struct VarDescr
{
VarDescr(LPCSTR var, LPCSTR value) :
szVar(mir_strdup(var)),
szValue(mir_strdup(value))
- {}
+ {}
VarDescr(LPCSTR var, LPSTR value) :
szVar(mir_strdup(var)),
szValue(value)
- {}
+ {}
VarDescr(LPCSTR var, PBYTE value, int len) :
szVar(mir_strdup(var)),
szValue((char*)memcpy(mir_alloc(len), value, len)),
iLen(len)
- {}
+ {}
ptrA szVar, szValue;
int iLen;
};
-struct SettingUgraderParam
-{
- CDb3Mmap *db;
- LPCSTR szModule;
- MCONTACT contactID;
- OBJLIST<VarDescr>* pList;
-};
-
-int sttSettingUgrader(const char *szSetting, LPARAM lParam)
-{
- SettingUgraderParam *param = (SettingUgraderParam*)lParam;
- if (param->db->IsSettingEncrypted(param->szModule, szSetting)) {
- DBVARIANT dbv = { DBVT_UTF8 };
- if (!param->db->GetContactSettingStr(param->contactID, param->szModule, szSetting, &dbv)) {
- if (dbv.type == DBVT_UTF8) {
- DecodeString(dbv.pszVal);
- param->pList->insert(new VarDescr(szSetting, (LPCSTR)dbv.pszVal));
- }
- param->db->FreeVariant(&dbv);
- }
- }
- return 0;
-}
-
-void sttContactEnum(MCONTACT contactID, const char *szModule, CDb3Mmap *db)
-{
- OBJLIST<VarDescr> arSettings(1);
- SettingUgraderParam param = { db, szModule, contactID, &arSettings };
-
- DBCONTACTENUMSETTINGS dbces = { 0 };
- dbces.pfnEnumProc = sttSettingUgrader;
- dbces.szModule = szModule;
- dbces.lParam = (LPARAM)¶m;
- db->EnumContactSettings(NULL, &dbces);
-
- for (int i = 0; i < arSettings.getCount(); i++) {
- VarDescr &p = arSettings[i];
-
- size_t len;
- BYTE *pResult = db->m_crypto->encodeString(p.szValue, &len);
- if (pResult != NULL) {
- DBCONTACTWRITESETTING dbcws = { szModule, p.szVar };
- dbcws.value.type = DBVT_ENCRYPTED;
- dbcws.value.pbVal = pResult;
- dbcws.value.cpbVal = (WORD)len;
- db->WriteContactSetting(contactID, &dbcws);
-
- mir_free(pResult);
- }
- }
-}
-
-int sttModuleEnum(const char *szModule, DWORD, LPARAM lParam)
-{
- CDb3Mmap *db = (CDb3Mmap*)lParam;
- sttContactEnum(NULL, szModule, db);
-
- for (MCONTACT contactID = db->FindFirstContact(); contactID; contactID = db->FindNextContact(contactID))
- sttContactEnum(contactID, szModule, db);
-
- return 0;
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
int CDb3Mmap::InitCrypt()
{
- if (m_dbHeader.version == DB_OLD_VERSION)
- return 0;
-
CRYPTO_PROVIDER *pProvider;
DBVARIANT dbv = { 0 };
@@ -176,26 +94,13 @@ LBL_SetNewKey: if (memcmp(m_dbHeader.signature, &dbSignatureE, sizeof(m_dbHeader.signature)))
goto LBL_SetNewKey;
- if (!EnterPassword(dbv.pbVal, iKeyLength)) { // password protected?
- if (m_dbHeader.version >= DB_094_VERSION)
- return 4;
-
- // one of the early used version of mmap was replaced then by mmap_sa
- // simply remove old badly generated key
- goto LBL_SetNewKey;
- }
+ if (!EnterPassword(dbv.pbVal, iKeyLength)) // password protected?
+ return 4;
}
FreeVariant(&dbv);
}
- if (!memcmp(&m_dbHeader.signature, &dbSignatureIM, sizeof(m_dbHeader.signature))) {
- EnumModuleNames(sttModuleEnum, this);
-
- // upgrade signature
- WriteSignature(dbSignatureU);
- }
-
dbv.type = DBVT_BYTE;
if (!GetContactSetting(NULL, "CryptoEngine", "DatabaseEncryption", &dbv))
m_bEncrypted = dbv.bVal != 0;
diff --git a/plugins/Db3x_mmap/src/dbheaders.cpp b/plugins/Db3x_mmap/src/dbheaders.cpp index 102fd56fac..8f39fada64 100644 --- a/plugins/Db3x_mmap/src/dbheaders.cpp +++ b/plugins/Db3x_mmap/src/dbheaders.cpp @@ -52,19 +52,41 @@ int CDb3Mmap::CreateDbHeaders(const DBSignature& _sign) return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static TCHAR tszOldHeaders[] = _T("Miranda cannot open the obsolete database. Press Yes to download a solution or No to cancel");
+
int CDb3Mmap::CheckDbHeaders()
{
- if (memcmp(m_dbHeader.signature, &dbSignatureU, sizeof(m_dbHeader.signature)) &&
- memcmp(m_dbHeader.signature, &dbSignatureE, sizeof(m_dbHeader.signature)) &&
- memcmp(m_dbHeader.signature, &dbSignatureIM, sizeof(m_dbHeader.signature)))
+ if (memcmp(m_dbHeader.signature, &dbSignatureU, sizeof(m_dbHeader.signature)) &&
+ memcmp(m_dbHeader.signature, &dbSignatureE, sizeof(m_dbHeader.signature)))
+ {
+ if (!memcmp(&m_dbHeader.signature, &dbSignatureIM, sizeof(m_dbHeader.signature)) ||
+ !memcmp(&m_dbHeader.signature, &dbSignatureSA, sizeof(m_dbHeader.signature)) ||
+ !memcmp(&m_dbHeader.signature, &dbSignatureSD, sizeof(m_dbHeader.signature)))
+ {
+ if (IDYES == MessageBox(NULL, TranslateTS(tszOldHeaders), TranslateT("Obsolete database format"), MB_YESNO | MB_ICONHAND)) {
+ TCHAR tszCurPath[MAX_PATH];
+ GetModuleFileName(NULL, tszCurPath, SIZEOF(tszCurPath));
+
+ HKEY hPathSetting;
+ if (!RegCreateKey(HKEY_CURRENT_USER, _T("Software\\Miranda NG"), &hPathSetting)) {
+ RegSetValue(hPathSetting, _T("InstallPath"), REG_SZ, tszCurPath, sizeof(tszCurPath));
+ RegCloseKey(hPathSetting);
+ }
+
+ CallService(MS_UTILS_OPENURL, 0, LPARAM("http://wiki.miranda-ng.org/index.php?title=Updating_pre-0.94.9_version_to_0.95.1_and_later"));
+ exit(0);
+ }
+ }
return EGROKPRF_UNKHEADER;
+ }
switch (m_dbHeader.version) {
case DB_095_1_VERSION:
case DB_095_VERSION:
- case DB_094_VERSION:
- case DB_OLD_VERSION:
break;
+
default:
return EGROKPRF_VERNEWER;
}
diff --git a/plugins/Db3x_mmap/src/dbintf.cpp b/plugins/Db3x_mmap/src/dbintf.cpp index 0e2187e993..d256adefe1 100644 --- a/plugins/Db3x_mmap/src/dbintf.cpp +++ b/plugins/Db3x_mmap/src/dbintf.cpp @@ -27,6 +27,7 @@ DBSignature dbSignatureU = { "Miranda NG DBu", 0x1A }; // unencrypted database DBSignature dbSignatureE = { "Miranda NG DBe", 0x1A }; // encrypted database
DBSignature dbSignatureIM = { "Miranda ICQ DB", 0x1A };
DBSignature dbSignatureSA = { "Miranda ICQ SA", 0x1A };
+DBSignature dbSignatureSD = { "Miranda ICQ SD", 0x1A };
static int ModCompare(const ModuleName *mn1, const ModuleName *mn2)
{
@@ -92,7 +93,7 @@ CDb3Mmap::~CDb3Mmap() if (!m_bReadOnly) {
DWORD bytesWritten;
SetFilePointer(m_hDbFile, 0, NULL, FILE_BEGIN);
- WriteFile(m_hDbFile, &dbSignatureIM, 1, &bytesWritten, NULL);
+ WriteFile(m_hDbFile, &dbSignatureU, 1, &bytesWritten, NULL);
}
if (m_hDbFile != INVALID_HANDLE_VALUE)
@@ -138,9 +139,6 @@ int CDb3Mmap::Load(bool bSkipInit) return EGROKPRF_CANTREAD;
}
- if (!memcmp(&m_dbHeader.signature, &dbSignatureSA, sizeof(m_dbHeader.signature)))
- memcpy(&m_dbHeader.signature, &dbSignatureIM, sizeof(m_dbHeader.signature));
-
if (!bSkipInit) {
if (InitMap()) return 1;
if (InitModuleNames()) return 1;
diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h index 2953a06b57..b69054f87d 100644 --- a/plugins/Db3x_mmap/src/dbintf.h +++ b/plugins/Db3x_mmap/src/dbintf.h @@ -47,8 +47,6 @@ DBHeader #define DBMODE_SHARED 0x0001
#define DBMODE_READONLY 0x0002
-#define DB_OLD_VERSION 0x00000700u
-#define DB_094_VERSION 0x00000701u
#define DB_095_VERSION 0x00000800u
#define DB_095_1_VERSION 0x00000801u
diff --git a/plugins/Db3x_mmap/src/version.h b/plugins/Db3x_mmap/src/version.h index 2f1eb214a5..f625baeeeb 100644 --- a/plugins/Db3x_mmap/src/version.h +++ b/plugins/Db3x_mmap/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 95
-#define __RELEASE_NUM 0
-#define __BUILD_NUM 4
+#define __RELEASE_NUM 1
+#define __BUILD_NUM 1
#include <stdver.h>
|