summaryrefslogtreecommitdiff
path: root/plugins/Mir_core
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-06-28 21:28:50 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-06-28 21:28:50 +0000
commit190968e9803a32bd4e609176989564735098146c (patch)
treea3ab28871ffd27d84f401ebd9e4f79423c1823e8 /plugins/Mir_core
parent46c66c9252010602ba3194956e7710946066879b (diff)
database stubs moved to mir_core
git-svn-id: http://svn.miranda-ng.org/main/trunk@676 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Mir_core')
-rw-r--r--plugins/Mir_core/db.cpp191
-rw-r--r--plugins/Mir_core/mir_core.def16
-rw-r--r--plugins/Mir_core/mir_core_10.vcxproj4
-rw-r--r--plugins/Mir_core/mir_core_10.vcxproj.filters6
4 files changed, 217 insertions, 0 deletions
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 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\m_core.h" />
+ <ClInclude Include="..\..\include\m_database.h" />
<ClInclude Include="..\..\include\m_system.h" />
<ClInclude Include="commonheaders.h" />
<ClInclude Include="forkthread.h" />
@@ -33,6 +34,7 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
+ <ClCompile Include="db.cpp" />
<ClCompile Include="langpack.cpp" />
<ClCompile Include="lists.cpp" />
<ClCompile Include="md5.cpp" />
@@ -149,6 +151,7 @@
<AdditionalDependencies>miranda64.lib;ws2_32.lib;comctl32.lib;winmm.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>
</AdditionalLibraryDirectories>
+ <AdditionalOptions>/ignore:4197 %(AdditionalOptions)</AdditionalOptions>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -213,6 +216,7 @@
<AdditionalDependencies>miranda64.lib;ws2_32.lib;comctl32.lib;winmm.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>
</AdditionalLibraryDirectories>
+ <AdditionalOptions>/ignore:4197 %(AdditionalOptions)</AdditionalOptions>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
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 @@
<ClCompile Include="sha1.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="db.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="commonheaders.h">
@@ -63,5 +66,8 @@
<ClInclude Include="..\..\include\m_system.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\..\include\m_database.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
</Project> \ No newline at end of file