summaryrefslogtreecommitdiff
path: root/protocols/Quotes/DBUtils.cpp
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2012-06-06 08:58:27 +0000
committerKirill Volinsky <mataes2007@gmail.com>2012-06-06 08:58:27 +0000
commitb61ba851da0157ace3bdfc1ebbf87156b0b76413 (patch)
treed6c567db57af1eb09c254a8bee13c305282334f8 /protocols/Quotes/DBUtils.cpp
parenta4c70f6bedb25e5cffb08dfc5cbc2597d1642d6b (diff)
protocols plugins moved to protocols
git-svn-id: http://svn.miranda-ng.org/main/trunk@327 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Quotes/DBUtils.cpp')
-rw-r--r--protocols/Quotes/DBUtils.cpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/protocols/Quotes/DBUtils.cpp b/protocols/Quotes/DBUtils.cpp
new file mode 100644
index 0000000000..11c0fb3d0d
--- /dev/null
+++ b/protocols/Quotes/DBUtils.cpp
@@ -0,0 +1,70 @@
+#include "StdAfx.h"
+#include "DBUtils.h"
+
+std::string Quotes_DBGetStringA(HANDLE hContact,const char* szModule,const char* szSetting,const char* pszDefValue /*= NULL*/)
+{
+ std::string sResult;
+ char* pszSymbol = DBGetString(hContact,szModule,szSetting);
+ if(NULL != pszSymbol)
+ {
+ sResult = pszSymbol;
+ mir_free(pszSymbol);
+ }
+ else if(NULL != pszDefValue)
+ {
+ sResult = pszDefValue;
+ }
+
+ return sResult;
+}
+
+std::wstring Quotes_DBGetStringW(HANDLE hContact,const char* szModule,const char* szSetting,const wchar_t* pszDefValue/* = NULL*/)
+{
+ std::wstring sResult;
+ wchar_t* pszSymbol = DBGetStringW(hContact,szModule,szSetting);
+ if(NULL != pszSymbol)
+ {
+ sResult = pszSymbol;
+ mir_free(pszSymbol);
+ }
+ else if(NULL != pszDefValue)
+ {
+ sResult = pszDefValue;
+ }
+
+ return sResult;
+}
+
+bool Quotes_DBWriteDouble(HANDLE hContact,const char* szModule,const char* szSetting,double dValue)
+{
+ DBCONTACTWRITESETTING cws = {0};
+
+ cws.szModule = szModule;
+ cws.szSetting = szSetting;
+ cws.value.type = DBVT_BLOB;
+ cws.value.cpbVal = sizeof(dValue);
+ cws.value.pbVal = reinterpret_cast<BYTE*>(&dValue);
+ return 0 == CallService(MS_DB_CONTACT_WRITESETTING,reinterpret_cast<WPARAM>(hContact),reinterpret_cast<LPARAM>(&cws));
+}
+
+bool Quotes_DBReadDouble(HANDLE hContact,const char* szModule,const char* szSetting,double& rdValue)
+{
+ DBVARIANT dbv = {0};
+ DBCONTACTGETSETTING cgs;
+ cgs.szModule=szModule;
+ cgs.szSetting=szSetting;
+ cgs.pValue = &dbv;
+ dbv.type = DBVT_BLOB;
+
+ bool bResult = ((0 == CallService(MS_DB_CONTACT_GETSETTING,(WPARAM)hContact,(LPARAM)&cgs))
+ && (DBVT_BLOB == dbv.type));
+
+ if(bResult)
+ {
+ rdValue = *reinterpret_cast<double*>(dbv.pbVal);
+ }
+
+ DBFreeVariant(&dbv);
+ return bResult;
+}
+