From dd2dd9a224ea7501a99e0ae4995d8f4b8ed3b5c7 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 13 Nov 2018 23:52:10 +0300 Subject: NewsAggregator -> g_plugin --- plugins/NewsAggregator/Src/CheckFeed.cpp | 76 ++++++++++++++++---------------- 1 file changed, 37 insertions(+), 39 deletions(-) (limited to 'plugins/NewsAggregator/Src/CheckFeed.cpp') diff --git a/plugins/NewsAggregator/Src/CheckFeed.cpp b/plugins/NewsAggregator/Src/CheckFeed.cpp index fd01491274..9371609b63 100644 --- a/plugins/NewsAggregator/Src/CheckFeed.cpp +++ b/plugins/NewsAggregator/Src/CheckFeed.cpp @@ -112,7 +112,7 @@ LPCTSTR CheckFeed(wchar_t *tszURL, CFeedEditor *pEditDlg) static void XmlToMsg(MCONTACT hContact, CMStringW &title, CMStringW &link, CMStringW &descr, CMStringW &author, CMStringW &comments, CMStringW &guid, CMStringW &category, time_t stamp) { - CMStringW message = db_get_wsa(hContact, MODULENAME, "MsgFormat"); + CMStringW message = g_plugin.getWStringA(hContact, "MsgFormat"); if (!message) message = TAGSDEFAULT; @@ -190,10 +190,10 @@ static void XmlToMsg(MCONTACT hContact, CMStringW &title, CMStringW &link, CMStr void CheckCurrentFeed(MCONTACT hContact) { // Check is disabled by the user? - if (!db_get_b(hContact, MODULENAME, "CheckState", 1) != 0) + if (!g_plugin.getByte(hContact, "CheckState", 1) != 0) return; - wchar_t *szURL = db_get_wsa(hContact, MODULENAME, "URL"); + wchar_t *szURL = g_plugin.getWStringA(hContact, "URL"); if (szURL == nullptr) return; @@ -252,13 +252,13 @@ void CheckCurrentFeed(MCONTACT hContact) if (!mir_wstrcmpi(szAttrName, L"version")) { wchar_t ver[MAX_PATH]; mir_snwprintf(ver, L"RSS %s", xmlGetAttrValue(node, szAttrName)); - db_set_ws(hContact, MODULENAME, "MirVer", ver); + g_plugin.setWString(hContact, "MirVer", ver); break; } } } else if (isAtom) - db_set_ws(hContact, MODULENAME, "MirVer", L"RSS 1.0"); + g_plugin.setWString(hContact, "MirVer", L"RSS 1.0"); HXML chan = xmlGetChild(node, 0); for (int j = 0; j < xmlGetChildCount(chan); j++) { @@ -274,7 +274,7 @@ void CheckCurrentFeed(MCONTACT hContact) else szChildText = xmlGetText(child); if (szChildText) - db_set_ws(hContact, MODULENAME, "FirstName", ClearText(szValue, szChildText)); + g_plugin.setWString(hContact, "FirstName", ClearText(szValue, szChildText)); } else if (!mir_wstrcmpi(childName, L"link")) { LPCTSTR szChildText = nullptr; @@ -286,7 +286,7 @@ void CheckCurrentFeed(MCONTACT hContact) else szChildText = xmlGetText(child); if (szChildText) - db_set_ws(hContact, MODULENAME, "Homepage", ClearText(szValue, szChildText)); + g_plugin.setWString(hContact, "Homepage", ClearText(szValue, szChildText)); } else if (!mir_wstrcmpi(childName, L"description")) { LPCTSTR szChildText = nullptr; @@ -299,7 +299,7 @@ void CheckCurrentFeed(MCONTACT hContact) szChildText = xmlGetText(child); if (szChildText) { ClearText(szValue, szChildText); - db_set_ws(hContact, MODULENAME, "About", szValue); + g_plugin.setWString(hContact, "About", szValue); db_set_ws(hContact, "CList", "StatusMsg", szValue); } } @@ -313,7 +313,7 @@ void CheckCurrentFeed(MCONTACT hContact) else szChildText = xmlGetText(child); if (szChildText) - db_set_ws(hContact, MODULENAME, "Language1", ClearText(szValue, szChildText)); + g_plugin.setWString(hContact, "Language1", ClearText(szValue, szChildText)); } else if (!mir_wstrcmpi(childName, L"managingEditor")) { LPCTSTR szChildText = nullptr; @@ -325,7 +325,7 @@ void CheckCurrentFeed(MCONTACT hContact) else szChildText = xmlGetText(child); if (szChildText) - db_set_ws(hContact, MODULENAME, "e-mail", ClearText(szValue, szChildText)); + g_plugin.setWString(hContact, "e-mail", ClearText(szValue, szChildText)); } else if (!mir_wstrcmpi(childName, L"category")) { LPCTSTR szChildText = nullptr; @@ -337,7 +337,7 @@ void CheckCurrentFeed(MCONTACT hContact) else szChildText = xmlGetText(child); if (szChildText) - db_set_ws(hContact, MODULENAME, "Interest0Text", ClearText(szValue, szChildText)); + g_plugin.setWString(hContact, "Interest0Text", ClearText(szValue, szChildText)); } else if (!mir_wstrcmpi(childName, L"copyright")) { LPCTSTR szChildText = nullptr; @@ -356,12 +356,12 @@ void CheckCurrentFeed(MCONTACT hContact) HXML imageval = xmlGetChild(child, x); if (!mir_wstrcmpi(xmlGetName(imageval), L"url")) { LPCTSTR url = xmlGetText(imageval); - db_set_ws(hContact, MODULENAME, "ImageURL", url); + g_plugin.setWString(hContact, "ImageURL", url); PROTO_AVATAR_INFORMATION ai = { 0 }; ai.hContact = hContact; - wchar_t *szNick = db_get_wsa(hContact, MODULENAME, "Nick"); + ptrW szNick(g_plugin.getWStringA(hContact, "Nick")); if (szNick) { wchar_t *ext = wcsrchr((wchar_t *)url, '.') + 1; ai.format = ProtoGetAvatarFormat(url); @@ -371,11 +371,10 @@ void CheckCurrentFeed(MCONTACT hContact) mir_snwprintf(ai.filename, L"%s\\%s.%s", tszRoot, filename.c_str(), ext); CreateDirectoryTreeW(tszRoot); if (DownloadFile(url, ai.filename)) { - db_set_ws(hContact, MODULENAME, "ImagePath", ai.filename); + g_plugin.setWString(hContact, "ImagePath", ai.filename); ProtoBroadcastAck(MODULENAME, hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&ai, NULL); } else ProtoBroadcastAck(MODULENAME, hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, (HANDLE)&ai, NULL); - mir_free(szNick); break; } } @@ -393,9 +392,9 @@ void CheckCurrentFeed(MCONTACT hContact) if (szChildText) { time_t stamp = DateToUnixTime(szChildText, 0); double deltaupd = difftime(time(0), stamp); - double deltacheck = difftime(time(0), (time_t)db_get_dw(hContact, MODULENAME, "LastCheck", 0)); + double deltacheck = difftime(time(0), (time_t)g_plugin.getDword(hContact, "LastCheck")); if (deltaupd - deltacheck >= 0) { - db_set_dw(hContact, MODULENAME, "LastCheck", (DWORD)time(0)); + g_plugin.setDword(hContact, "LastCheck", time(0)); xmlDestroyNode(hXml); return; } @@ -448,14 +447,14 @@ void CheckCurrentFeed(MCONTACT hContact) } } else if (!mir_wstrcmpi(szNodeName, L"feed")) { - db_set_ws(hContact, MODULENAME, "MirVer", L"Atom 3"); + g_plugin.setWString(hContact, "MirVer", L"Atom 3"); for (int j = 0; j < xmlGetChildCount(node); j++) { HXML child = xmlGetChild(node, j); LPCTSTR szChildName = xmlGetName(child); if (!mir_wstrcmpi(szChildName, L"title")) { LPCTSTR szChildText = xmlGetText(child); if (szChildText) - db_set_ws(hContact, MODULENAME, "FirstName", ClearText(szValue, szChildText)); + g_plugin.setWString(hContact, "FirstName", ClearText(szValue, szChildText)); } else if (!mir_wstrcmpi(szChildName, L"link")) { for (int x = 0; x < xmlGetAttrCount(child); x++) { @@ -464,27 +463,27 @@ void CheckCurrentFeed(MCONTACT hContact) break; if (!mir_wstrcmpi(xmlGetAttrName(child, x), L"href")) - db_set_ws(hContact, MODULENAME, "Homepage", xmlGetAttrValue(child, xmlGetAttrName(child, x))); + g_plugin.setWString(hContact, "Homepage", xmlGetAttrValue(child, xmlGetAttrName(child, x))); } } else if (!mir_wstrcmpi(szChildName, L"subtitle")) { LPCTSTR szChildText = xmlGetText(child); if (szChildText) { ClearText(szValue, szChildText); - db_set_ws(hContact, MODULENAME, "About", szValue); + g_plugin.setWString(hContact, "About", szValue); db_set_ws(hContact, "CList", "StatusMsg", szValue); } } else if (!mir_wstrcmpi(szChildName, L"language")) { LPCTSTR szChildText = xmlGetText(child); if (szChildText) - db_set_ws(hContact, MODULENAME, "Language1", ClearText(szValue, szChildText)); + g_plugin.setWString(hContact, "Language1", ClearText(szValue, szChildText)); } else if (!mir_wstrcmpi(szChildName, L"author")) { for (int x = 0; x < xmlGetChildCount(child); x++) { HXML authorval = xmlGetChild(child, x); if (!mir_wstrcmpi(xmlGetName(authorval), L"email")) { - db_set_ws(hContact, MODULENAME, "e-mail", xmlGetText(authorval)); + g_plugin.setWString(hContact, "e-mail", xmlGetText(authorval)); break; } } @@ -492,16 +491,16 @@ void CheckCurrentFeed(MCONTACT hContact) else if (!mir_wstrcmpi(szChildName, L"category")) { LPCTSTR szChildText = xmlGetText(child); if (szChildText) - db_set_ws(hContact, MODULENAME, "Interest0Text", ClearText(szValue, szChildText)); + g_plugin.setWString(hContact, "Interest0Text", ClearText(szValue, szChildText)); } else if (!mir_wstrcmpi(szChildName, L"icon")) { for (int x = 0; x < xmlGetChildCount(child); x++) { HXML imageval = xmlGetChild(child, x); if (!mir_wstrcmpi(xmlGetName(imageval), L"url")) { LPCTSTR url = xmlGetText(imageval); - db_set_ws(hContact, MODULENAME, "ImageURL", url); + g_plugin.setWString(hContact, "ImageURL", url); - ptrW szNick(db_get_wsa(hContact, MODULENAME, "Nick")); + ptrW szNick(g_plugin.getWStringA(hContact, "Nick")); if (szNick) { PROTO_AVATAR_INFORMATION ai = { 0 }; ai.hContact = hContact; @@ -511,7 +510,7 @@ void CheckCurrentFeed(MCONTACT hContact) wchar_t *filename = szNick; mir_snwprintf(ai.filename, L"%s\\%s.%s", tszRoot, filename, ext); if (DownloadFile(url, ai.filename)) { - db_set_ws(hContact, MODULENAME, "ImagePath", ai.filename); + g_plugin.setWString(hContact, "ImagePath", ai.filename); ProtoBroadcastAck(MODULENAME, hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&ai, NULL); } else ProtoBroadcastAck(MODULENAME, hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, (HANDLE)&ai, NULL); @@ -526,9 +525,9 @@ void CheckCurrentFeed(MCONTACT hContact) wchar_t *lastupdtime = (wchar_t *)szChildText; time_t stamp = DateToUnixTime(lastupdtime, 1); double deltaupd = difftime(time(0), stamp); - double deltacheck = difftime(time(0), (time_t)db_get_dw(hContact, MODULENAME, "LastCheck", 0)); + double deltacheck = difftime(time(0), (time_t)g_plugin.getDword(hContact, "LastCheck")); if (deltaupd - deltacheck >= 0) { - db_set_dw(hContact, MODULENAME, "LastCheck", (DWORD)time(0)); + g_plugin.setDword(hContact, "LastCheck", time(0)); xmlDestroyNode(hXml); return; } @@ -601,15 +600,15 @@ void CheckCurrentFeed(MCONTACT hContact) xmlDestroyNode(hXml); } } - db_set_dw(hContact, MODULENAME, "LastCheck", (DWORD)time(0)); + g_plugin.setDword(hContact, "LastCheck", time(0)); } void CheckCurrentFeedAvatar(MCONTACT hContact) { - if (!db_get_b(hContact, MODULENAME, "CheckState", 1)) + if (!g_plugin.getByte(hContact, "CheckState", 1)) return; - wchar_t *szURL = db_get_wsa(hContact, MODULENAME, "URL"); + wchar_t *szURL = g_plugin.getWStringA(hContact, "URL"); if (szURL == nullptr) return; @@ -643,12 +642,12 @@ void CheckCurrentFeedAvatar(MCONTACT hContact) HXML imageval = xmlGetChild(child, x); if (!mir_wstrcmpi(xmlGetName(imageval), L"url")) { LPCTSTR url = xmlGetText(imageval); - db_set_ws(hContact, MODULENAME, "ImageURL", url); + g_plugin.setWString(hContact, "ImageURL", url); PROTO_AVATAR_INFORMATION ai = { 0 }; ai.hContact = hContact; - wchar_t *szNick = db_get_wsa(hContact, MODULENAME, "Nick"); + ptrW szNick(g_plugin.getWStringA(hContact, "Nick")); if (szNick) { wchar_t *ext = wcsrchr((wchar_t *)url, '.') + 1; ai.format = ProtoGetAvatarFormat(ext); @@ -656,11 +655,10 @@ void CheckCurrentFeedAvatar(MCONTACT hContact) wchar_t *filename = szNick; mir_snwprintf(ai.filename, L"%s\\%s.%s", tszRoot, filename, ext); if (DownloadFile(url, ai.filename)) { - db_set_ws(hContact, MODULENAME, "ImagePath", ai.filename); + g_plugin.setWString(hContact, "ImagePath", ai.filename); ProtoBroadcastAck(MODULENAME, hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&ai, NULL); } else ProtoBroadcastAck(MODULENAME, hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, (HANDLE)&ai, NULL); - mir_free(szNick); break; } } @@ -676,9 +674,9 @@ void CheckCurrentFeedAvatar(MCONTACT hContact) HXML imageval = xmlGetChild(child, x); if (!mir_wstrcmpi(xmlGetName(imageval), L"url")) { LPCTSTR url = xmlGetText(imageval); - db_set_ws(hContact, MODULENAME, "ImageURL", url); + g_plugin.setWString(hContact, "ImageURL", url); - ptrW szNick(db_get_wsa(hContact, MODULENAME, "Nick")); + ptrW szNick(g_plugin.getWStringA(hContact, "Nick")); if (szNick) { PROTO_AVATAR_INFORMATION ai = { 0 }; ai.hContact = hContact; @@ -689,7 +687,7 @@ void CheckCurrentFeedAvatar(MCONTACT hContact) wchar_t *filename = szNick; mir_snwprintf(ai.filename, L"%s\\%s.%s", tszRoot, filename, ext); if (DownloadFile(url, ai.filename)) { - db_set_ws(hContact, MODULENAME, "ImagePath", ai.filename); + g_plugin.setWString(hContact, "ImagePath", ai.filename); ProtoBroadcastAck(MODULENAME, hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&ai, NULL); } else ProtoBroadcastAck(MODULENAME, hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, (HANDLE)&ai, NULL); -- cgit v1.2.3