diff options
author | George Hazan <george.hazan@gmail.com> | 2014-01-13 14:33:33 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-01-13 14:33:33 +0000 |
commit | 6d7087f75d1c08474e69ae4325afd0b661d71c1e (patch) | |
tree | 210725701e344187abde5e8b969b14c06d69b24a | |
parent | 22ae5f6a0f193c001185374c71c10495cbbd7df5 (diff) |
ability to detect whether a setting is encrypted or not
git-svn-id: http://svn.miranda-ng.org/main/trunk@7629 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | include/m_db_int.h | 1 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbcrypt.cpp | 6 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbintf.h | 1 | ||||
-rw-r--r-- | plugins/Db3x_mmap/src/dbsettings.cpp | 4 | ||||
-rw-r--r-- | plugins/Dbx_tree/src/Compatibility.cpp | 6 | ||||
-rw-r--r-- | plugins/Dbx_tree/src/DataBase.h | 1 |
6 files changed, 13 insertions, 6 deletions
diff --git a/include/m_db_int.h b/include/m_db_int.h index 5c9c093f7d..2d07e67896 100644 --- a/include/m_db_int.h +++ b/include/m_db_int.h @@ -103,6 +103,7 @@ interface MIDatabase STDMETHOD_(BOOL,EnumContactSettings)(HANDLE hContact, DBCONTACTENUMSETTINGS* dbces) PURE;
STDMETHOD_(BOOL,SetSettingResident)(BOOL bIsResident, const char *pszSettingName) PURE;
STDMETHOD_(BOOL,EnumResidentSettings)(DBMODULEENUMPROC pFunc, void *pParam) PURE;
+ STDMETHOD_(BOOL,IsSettingEncrypted)(LPCSTR szModule, LPCSTR szSetting) PURE;
};
///////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/Db3x_mmap/src/dbcrypt.cpp b/plugins/Db3x_mmap/src/dbcrypt.cpp index 922e7c006b..8af1b93b2f 100644 --- a/plugins/Db3x_mmap/src/dbcrypt.cpp +++ b/plugins/Db3x_mmap/src/dbcrypt.cpp @@ -25,8 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////////////////////////
-bool isEncrypted(LPCSTR szModule, LPCSTR szSetting);
-
//VERY VERY VERY BASIC ENCRYPTION FUNCTION
static void Encrypt(char *msg, BOOL up)
@@ -74,7 +72,7 @@ struct SettingUgraderParam int sttSettingUgrader(const char *szSetting, LPARAM lParam)
{
SettingUgraderParam *param = (SettingUgraderParam*)lParam;
- if (isEncrypted(param->szModule, szSetting)) {
+ if (param->db->IsSettingEncrypted(param->szModule, szSetting)) {
DBVARIANT dbv = { DBVT_UTF8 };
DBCONTACTGETSETTING dbcgs = { param->szModule, szSetting, &dbv };
if (!param->db->GetContactSettingStr(param->hContact, &dbcgs)) {
@@ -326,7 +324,7 @@ void CDb3Mmap::ToggleSettingsEncryption(HANDLE hContact) case DBVT_ENCRYPTED:
len = *(PWORD)(pBlob + 1);
// we need to decrypt these strings
- if (m_bEncrypted && !::isEncrypted(szModule, szSetting))
+ if (m_bEncrypted && !IsSettingEncrypted(szModule, szSetting))
arSettings.insert(new VarDescr(szSetting, pBlob + 3, len));
NeedBytes(3 + len);
break;
diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h index 92e8a9e0b0..4103d2c02c 100644 --- a/plugins/Db3x_mmap/src/dbintf.h +++ b/plugins/Db3x_mmap/src/dbintf.h @@ -204,6 +204,7 @@ public: STDMETHODIMP_(BOOL) EnumContactSettings(HANDLE hContact, DBCONTACTENUMSETTINGS* dbces);
STDMETHODIMP_(BOOL) SetSettingResident(BOOL bIsResident, const char *pszSettingName);
STDMETHODIMP_(BOOL) EnumResidentSettings(DBMODULEENUMPROC pFunc, void *pParam);
+ STDMETHODIMP_(BOOL) IsSettingEncrypted(LPCSTR szModule, LPCSTR szSetting);
protected:
STDMETHODIMP_(BOOL) Start(DBCHeckCallback *callback);
diff --git a/plugins/Db3x_mmap/src/dbsettings.cpp b/plugins/Db3x_mmap/src/dbsettings.cpp index 34d60c68a4..29e92eb393 100644 --- a/plugins/Db3x_mmap/src/dbsettings.cpp +++ b/plugins/Db3x_mmap/src/dbsettings.cpp @@ -28,7 +28,7 @@ DBCachedContact* AddToCachedContactList(HANDLE hContact, int index); #define VLT(n) ((n == DBVT_UTF8 || n == DBVT_ENCRYPTED)?DBVT_ASCIIZ:n)
-bool isEncrypted(LPCSTR szModule, LPCSTR szSetting)
+BOOL CDb3Base::IsSettingEncrypted(LPCSTR szModule, LPCSTR szSetting)
{
if (!_strnicmp(szSetting, "password", 8)) return true;
if (!strcmp(szSetting, "NLProxyAuthPassword")) return true;
@@ -404,7 +404,7 @@ STDMETHODIMP_(BOOL) CDb3Base::WriteContactSetting(HANDLE hContact, DBCONTACTWRIT break;
case DBVT_ASCIIZ: case DBVT_UTF8:
- bIsEncrypted = m_bEncrypted || ::isEncrypted(dbcws->szModule, dbcws->szSetting);
+ bIsEncrypted = m_bEncrypted || IsSettingEncrypted(dbcws->szModule, dbcws->szSetting);
LBL_WriteString:
if (dbcwWork.value.pszVal == NULL)
return 1;
diff --git a/plugins/Dbx_tree/src/Compatibility.cpp b/plugins/Dbx_tree/src/Compatibility.cpp index 4ea0092e7b..4c04e63cf4 100644 --- a/plugins/Dbx_tree/src/Compatibility.cpp +++ b/plugins/Dbx_tree/src/Compatibility.cpp @@ -844,6 +844,12 @@ STDMETHODIMP_(BOOL) CDataBase::EnumResidentSettings(DBMODULEENUMPROC pFunc, void STDMETHODIMP_(void) CDataBase::SetCacheSafetyMode(BOOL) {}
+
+STDMETHODIMP_(BOOL) CDataBase::IsSettingEncrypted(LPCSTR szModule, LPCSTR szSetting)
+{
+ return FALSE;
+}
+
bool CompatibilityRegister()
{
hEventDeletedEvent = CreateHookableEvent(ME_DB_EVENT_DELETED);
diff --git a/plugins/Dbx_tree/src/DataBase.h b/plugins/Dbx_tree/src/DataBase.h index 539abd6564..0d03cd6f3d 100644 --- a/plugins/Dbx_tree/src/DataBase.h +++ b/plugins/Dbx_tree/src/DataBase.h @@ -226,6 +226,7 @@ protected: // to be compatible with the standard Miranda databases STDMETHODIMP_(BOOL) EnumContactSettings(HANDLE hContact, DBCONTACTENUMSETTINGS* dbces);
STDMETHODIMP_(BOOL) SetSettingResident(BOOL bIsResident, const char *pszSettingName);
STDMETHODIMP_(BOOL) EnumResidentSettings(DBMODULEENUMPROC pFunc, void *pParam);
+ STDMETHODIMP_(BOOL) IsSettingEncrypted(LPCSTR szModule, LPCSTR szSetting);
int CheckProto(HANDLE hContact, const char *proto);
};
|