summaryrefslogtreecommitdiff
path: root/protocols/Discord/src/utils.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2016-12-29 18:53:03 +0300
committerGeorge Hazan <ghazan@miranda.im>2016-12-29 18:53:03 +0300
commit50e87bcbf1b3a716f155e504a09df1c0ff1a66f5 (patch)
tree671924fd03f4f0a3a5da0af7cd4fe4cc841d54ad /protocols/Discord/src/utils.cpp
parent95ee503b0f0a4cb434de65f2d9d7375356e39d74 (diff)
support for the SnowFlake type for Miranda
Diffstat (limited to 'protocols/Discord/src/utils.cpp')
-rw-r--r--protocols/Discord/src/utils.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/protocols/Discord/src/utils.cpp b/protocols/Discord/src/utils.cpp
index 52eecea527..4d69a6f40f 100644
--- a/protocols/Discord/src/utils.cpp
+++ b/protocols/Discord/src/utils.cpp
@@ -43,3 +43,35 @@ JSONNode& operator<<(JSONNode &json, const WCHAR_PARAM &param)
json.push_back(JSONNode(param.szName, ptrA(mir_utf8encodeW(param.wszValue)).get()));
return json;
}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+SnowFlake CDiscordProto::getId(const char *szSetting)
+{
+ SnowFlake result;
+ DBVARIANT dbv;
+ dbv.type = DBVT_BLOB;
+ dbv.pbVal = (BYTE*)&result;
+ dbv.cpbVal = sizeof(result);
+ return (db_get(NULL, m_szModuleName, szSetting, &dbv)) ? 0 : result;
+}
+
+SnowFlake CDiscordProto::getId(MCONTACT hContact, const char *szSetting)
+{
+ SnowFlake result;
+ DBVARIANT dbv;
+ dbv.type = DBVT_BLOB;
+ dbv.pbVal = (BYTE*)&result;
+ dbv.cpbVal = sizeof(result);
+ return (db_get(hContact, m_szModuleName, szSetting, &dbv)) ? 0 : result;
+}
+
+void CDiscordProto::setId(const char *szSetting, SnowFlake iValue)
+{
+ db_set_blob(NULL, m_szModuleName, szSetting, &iValue, sizeof(iValue));
+}
+
+void CDiscordProto::setId(MCONTACT hContact, const char *szSetting, SnowFlake iValue)
+{
+ db_set_blob(hContact, m_szModuleName, szSetting, &iValue, sizeof(iValue));
+}