From 190968e9803a32bd4e609176989564735098146c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 28 Jun 2012 21:28:50 +0000 Subject: database stubs moved to mir_core git-svn-id: http://svn.miranda-ng.org/main/trunk@676 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Mir_core/db.cpp | 191 +++++++++++++++++++++++++++ plugins/Mir_core/mir_core.def | 16 +++ plugins/Mir_core/mir_core_10.vcxproj | 4 + plugins/Mir_core/mir_core_10.vcxproj.filters | 6 + 4 files changed, 217 insertions(+) create mode 100644 plugins/Mir_core/db.cpp (limited to 'plugins/Mir_core') diff --git a/plugins/Mir_core/db.cpp b/plugins/Mir_core/db.cpp new file mode 100644 index 0000000000..37b89d8399 --- /dev/null +++ b/plugins/Mir_core/db.cpp @@ -0,0 +1,191 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "commonheaders.h" + +MIR_CORE_DLL(int) db_get_b(HANDLE hContact, const char *szModule, const char *szSetting, int errorValue) +{ + DBVARIANT dbv; + DBCONTACTGETSETTING cgs; + cgs.szModule = szModule; + cgs.szSetting = szSetting; + cgs.pValue = &dbv; + if (CallService(MS_DB_CONTACT_GETSETTING, (WPARAM)hContact, (LPARAM)&cgs)) + return errorValue; + return dbv.bVal; +} + +MIR_CORE_DLL(int) db_get_w(HANDLE hContact, const char *szModule, const char *szSetting, int errorValue) +{ + DBVARIANT dbv; + DBCONTACTGETSETTING cgs; + cgs.szModule = szModule; + cgs.szSetting = szSetting; + cgs.pValue = &dbv; + if (CallService(MS_DB_CONTACT_GETSETTING, (WPARAM)hContact, (LPARAM)&cgs)) + return errorValue; + return dbv.wVal; +} + +MIR_CORE_DLL(DWORD) db_get_dw(HANDLE hContact, const char *szModule, const char *szSetting, DWORD errorValue) +{ + DBVARIANT dbv; + DBCONTACTGETSETTING cgs; + cgs.szModule = szModule; + cgs.szSetting = szSetting; + cgs.pValue = &dbv; + if (CallService(MS_DB_CONTACT_GETSETTING, (WPARAM)hContact, (LPARAM)&cgs)) + return errorValue; + return dbv.dVal; +} + +MIR_CORE_DLL(INT_PTR) db_get(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv) +{ + DBCONTACTGETSETTING cgs; + cgs.szModule = szModule; + cgs.szSetting = szSetting; + cgs.pValue = dbv; + + return CallService(MS_DB_CONTACT_GETSETTING, (WPARAM)hContact, (LPARAM)&cgs); +} + +MIR_CORE_DLL(INT_PTR) db_get_s(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv, const int nType) +{ + DBCONTACTGETSETTING cgs; + cgs.szModule = szModule; + cgs.szSetting = szSetting; + cgs.pValue = dbv; + dbv->type = (BYTE)nType; + return CallService(MS_DB_CONTACT_GETSETTING_STR, (WPARAM)hContact, (LPARAM)&cgs); +} + +MIR_CORE_DLL(char*) db_get_sa(HANDLE hContact, const char *szModule, const char *szSetting) +{ + char *str = NULL; + DBVARIANT dbv = {0}; + db_get_s(hContact, szModule, szSetting, &dbv, DBVT_ASCIIZ); + if (dbv.type == DBVT_ASCIIZ) + str = mir_strdup(dbv.pszVal); + DBFreeVariant(&dbv); + return str; +} + +MIR_CORE_DLL(wchar_t*) db_get_wsa(HANDLE hContact, const char *szModule, const char *szSetting) +{ + wchar_t *str = NULL; + DBVARIANT dbv={0}; + db_get_s(hContact, szModule, szSetting, &dbv, DBVT_WCHAR); + if (dbv.type == DBVT_WCHAR) + str = mir_wstrdup(dbv.pwszVal); + DBFreeVariant(&dbv); + return str; +} + +MIR_CORE_DLL(INT_PTR) db_free(DBVARIANT *dbv) +{ + return CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)dbv); +} + +MIR_CORE_DLL(INT_PTR) db_unset(HANDLE hContact, const char *szModule, const char *szSetting) +{ + DBCONTACTGETSETTING cgs; + cgs.szModule = szModule; + cgs.szSetting = szSetting; + return CallService(MS_DB_CONTACT_DELETESETTING, (WPARAM)hContact, (LPARAM)&cgs); +} + +MIR_CORE_DLL(INT_PTR) db_set_b(HANDLE hContact, const char *szModule, const char *szSetting, BYTE val) +{ + DBCONTACTWRITESETTING cws; + cws.szModule = szModule; + cws.szSetting = szSetting; + cws.value.type = DBVT_BYTE; + cws.value.bVal = val; + return CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)hContact, (LPARAM)&cws); +} + +MIR_CORE_DLL(INT_PTR) db_set_w(HANDLE hContact, const char *szModule, const char *szSetting, WORD val) +{ + DBCONTACTWRITESETTING cws; + + cws.szModule = szModule; + cws.szSetting = szSetting; + cws.value.type = DBVT_WORD; + cws.value.wVal = val; + return CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)hContact, (LPARAM)&cws); +} + +MIR_CORE_DLL(INT_PTR) db_set_dw(HANDLE hContact, const char *szModule, const char *szSetting, DWORD val) +{ + DBCONTACTWRITESETTING cws; + cws.szModule = szModule; + cws.szSetting = szSetting; + cws.value.type = DBVT_DWORD; + cws.value.dVal = val; + return CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)hContact, (LPARAM)&cws); +} + +MIR_CORE_DLL(INT_PTR) db_set_s(HANDLE hContact, const char *szModule, const char *szSetting, const char *val) +{ + DBCONTACTWRITESETTING cws; + + cws.szModule = szModule; + cws.szSetting = szSetting; + cws.value.type = DBVT_ASCIIZ; + cws.value.pszVal = (char*)val; + return CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)hContact, (LPARAM)&cws); +} + +MIR_CORE_DLL(INT_PTR) db_set_ws(HANDLE hContact, const char *szModule, const char *szSetting, const WCHAR *val) +{ + DBCONTACTWRITESETTING cws; + + cws.szModule = szModule; + cws.szSetting = szSetting; + cws.value.type = DBVT_WCHAR; + cws.value.pwszVal = (WCHAR*)val; + return CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)hContact, (LPARAM)&cws); +} + +MIR_CORE_DLL(INT_PTR) db_set_utf(HANDLE hContact, const char *szModule, const char *szSetting, const char *val) +{ + DBCONTACTWRITESETTING cws; + + cws.szModule = szModule; + cws.szSetting = szSetting; + cws.value.type = DBVT_UTF8; + cws.value.pszVal = (char*)val; + return CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)hContact, (LPARAM)&cws); +} + +MIR_CORE_DLL(INT_PTR) db_set_blob(HANDLE hContact, const char *szModule, const char *szSetting, void *val, unsigned len) +{ + DBCONTACTWRITESETTING cws; + + cws.szModule = szModule; + cws.szSetting = szSetting; + cws.value.type = DBVT_BLOB; + cws.value.cpbVal = (WORD)len; + cws.value.pbVal = (unsigned char*)val; + return CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)hContact, (LPARAM)&cws); +} diff --git a/plugins/Mir_core/mir_core.def b/plugins/Mir_core/mir_core.def index ac94078de8..323ef00961 100644 --- a/plugins/Mir_core/mir_core.def +++ b/plugins/Mir_core/mir_core.def @@ -107,3 +107,19 @@ wildcmp @103 wrtrim @104 mir_snprintf @105 mir_sntprintf @106 +db_unset @107 +db_free @108 +db_get @109 +db_get_b @110 +db_get_dw @111 +db_get_s @112 +db_get_sa @113 +db_get_w @114 +db_get_wsa @115 +db_set_b @116 +db_set_blob @117 +db_set_dw @118 +db_set_s @119 +db_set_utf @120 +db_set_w @121 +db_set_ws @122 diff --git a/plugins/Mir_core/mir_core_10.vcxproj b/plugins/Mir_core/mir_core_10.vcxproj index 1e6d7de8d1..68b4adf4d8 100644 --- a/plugins/Mir_core/mir_core_10.vcxproj +++ b/plugins/Mir_core/mir_core_10.vcxproj @@ -20,6 +20,7 @@ + @@ -33,6 +34,7 @@ Create Create + @@ -149,6 +151,7 @@ miranda64.lib;ws2_32.lib;comctl32.lib;winmm.lib;version.lib;%(AdditionalDependencies) + /ignore:4197 %(AdditionalOptions) @@ -213,6 +216,7 @@ miranda64.lib;ws2_32.lib;comctl32.lib;winmm.lib;version.lib;%(AdditionalDependencies) + /ignore:4197 %(AdditionalOptions) diff --git a/plugins/Mir_core/mir_core_10.vcxproj.filters b/plugins/Mir_core/mir_core_10.vcxproj.filters index 1a051134b1..1aca9fda03 100644 --- a/plugins/Mir_core/mir_core_10.vcxproj.filters +++ b/plugins/Mir_core/mir_core_10.vcxproj.filters @@ -43,6 +43,9 @@ Source Files + + Source Files + @@ -63,5 +66,8 @@ Header Files + + Header Files + \ No newline at end of file -- cgit v1.2.3