diff options
author | George Hazan <ghazan@miranda.im> | 2018-11-13 23:52:10 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-11-13 23:52:10 +0300 |
commit | dd2dd9a224ea7501a99e0ae4995d8f4b8ed3b5c7 (patch) | |
tree | 0c54acb21f7461e446627f156cb05ae1b5ba8f28 /plugins | |
parent | 453a2f5a1c3dbe0e2b87c2058a4e0ddf0c8f99c7 (diff) |
NewsAggregator -> g_plugin
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/NewsAggregator/Src/Authentication.cpp | 32 | ||||
-rw-r--r-- | plugins/NewsAggregator/Src/CheckFeed.cpp | 76 | ||||
-rw-r--r-- | plugins/NewsAggregator/Src/Options.cpp | 121 | ||||
-rw-r--r-- | plugins/NewsAggregator/Src/Services.cpp | 18 | ||||
-rw-r--r-- | plugins/NewsAggregator/Src/Update.cpp | 6 | ||||
-rw-r--r-- | plugins/NewsAggregator/Src/Utils.cpp | 6 |
6 files changed, 118 insertions, 141 deletions
diff --git a/plugins/NewsAggregator/Src/Authentication.cpp b/plugins/NewsAggregator/Src/Authentication.cpp index 04b70d4aa0..5e16abb3b8 100644 --- a/plugins/NewsAggregator/Src/Authentication.cpp +++ b/plugins/NewsAggregator/Src/Authentication.cpp @@ -22,9 +22,9 @@ Boston, MA 02111-1307, USA. void CreateAuthString(char *auth, MCONTACT hContact, CFeedEditor *pDlg)
{
wchar_t *tlogin = nullptr, *tpass = nullptr;
- if (hContact && db_get_b(hContact, MODULENAME, "UseAuth", 0)) {
- tlogin = db_get_wsa(hContact, MODULENAME, "Login");
- tpass = db_get_wsa(hContact, MODULENAME, "Password");
+ if (hContact && g_plugin.getByte(hContact, "UseAuth")) {
+ tlogin = g_plugin.getWStringA(hContact, "Login");
+ tpass = g_plugin.getWStringA(hContact, "Password");
}
else if (pDlg && pDlg->m_useauth.IsChecked()) {
tlogin = pDlg->m_login.GetText();
@@ -42,8 +42,8 @@ void CreateAuthString(char *auth, MCONTACT hContact, CFeedEditor *pDlg) mir_snprintf(auth, 250, "Basic %s", ptrA(mir_base64_encode(str, len)));
}
-CAuthRequest::CAuthRequest(CFeedEditor *pDlg, MCONTACT hContact)
- : CSuper(g_plugin, IDD_AUTHENTICATION),
+CAuthRequest::CAuthRequest(CFeedEditor *pDlg, MCONTACT hContact) :
+ CSuper(g_plugin, IDD_AUTHENTICATION),
m_feedname(this, IDC_FEEDNAME), m_username(this, IDC_FEEDUSERNAME),
m_password(this, IDC_FEEDPASSWORD), m_ok(this, IDOK)
{
@@ -65,18 +65,11 @@ bool CAuthRequest::OnInitDialog() }
}
else if (m_hContact) {
- wchar_t *ptszNick = db_get_wsa(m_hContact, MODULENAME, "Nick");
- if (ptszNick) {
+ ptrW ptszNick(g_plugin.getWStringA(m_hContact, "Nick"));
+ if (!ptszNick)
+ ptszNick = g_plugin.getWStringA(m_hContact, "URL");
+ if (ptszNick)
m_feedname.SetText(ptszNick);
- mir_free(ptszNick);
- }
- else {
- wchar_t *ptszURL = db_get_wsa(m_hContact, MODULENAME, "URL");
- if (ptszURL) {
- m_feedname.SetText(ptszURL);
- mir_free(ptszURL);
- }
- }
}
return true;
}
@@ -101,9 +94,8 @@ void CAuthRequest::OnOk(CCtrlBase*) m_pDlg->m_password.SetTextA(strfeedpassword);
}
else if (m_hContact) {
- db_set_b(m_hContact, MODULENAME, "UseAuth", 1);
- db_set_ws(m_hContact, MODULENAME, "Login", strfeedusername);
- db_set_s(m_hContact, MODULENAME, "Password", strfeedpassword);
-
+ g_plugin.setByte(m_hContact, "UseAuth", 1);
+ g_plugin.setWString(m_hContact, "Login", strfeedusername);
+ g_plugin.setString(m_hContact, "Password", strfeedpassword);
}
}
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);
diff --git a/plugins/NewsAggregator/Src/Options.cpp b/plugins/NewsAggregator/Src/Options.cpp index dd956d3f37..f11c4076de 100644 --- a/plugins/NewsAggregator/Src/Options.cpp +++ b/plugins/NewsAggregator/Src/Options.cpp @@ -40,11 +40,9 @@ bool CExportFeed::OnInitDialog() {
Utils_RestoreWindowPositionNoSize(m_hwnd, NULL, MODULENAME, "ExportDlg");
for (auto &hContact : Contacts(MODULENAME)) {
- wchar_t *message = db_get_wsa(hContact, MODULENAME, "Nick");
- if (message != nullptr) {
+ ptrW message(g_plugin.getWStringA(hContact, "Nick"));
+ if (message != nullptr)
m_feedslist.AddString(message);
- mir_free(message);
- }
}
m_removefeed.Disable();
m_removeallfeeds.Disable();
@@ -201,9 +199,9 @@ void CExportFeed::OnOk(CCtrlBase*) m_feedsexportlist.GetItemText(i, item, _countof(item));
MCONTACT hContact = GetContactByNick(item);
wchar_t
- *title = db_get_wsa(hContact, MODULENAME, "Nick"),
- *url = db_get_wsa(hContact, MODULENAME, "URL"),
- *siteurl = db_get_wsa(hContact, MODULENAME, "Homepage"),
+ *title = g_plugin.getWStringA(hContact, "Nick"),
+ *url = g_plugin.getWStringA(hContact, "URL"),
+ *siteurl = g_plugin.getWStringA(hContact, "Homepage"),
*group = db_get_wsa(hContact, "CList", "Group");
HXML elem = header;
@@ -605,13 +603,13 @@ void CImportFeed::OnOk(CCtrlBase*) MCONTACT hContact = db_add_contact();
Proto_AddToContact(hContact, MODULENAME);
- db_set_ws(hContact, MODULENAME, "Nick", text);
- db_set_ws(hContact, MODULENAME, "URL", url);
- db_set_ws(hContact, MODULENAME, "Homepage", siteurl);
- db_set_b(hContact, MODULENAME, "CheckState", 1);
- db_set_dw(hContact, MODULENAME, "UpdateTime", DEFAULT_UPDATE_TIME);
- db_set_ws(hContact, MODULENAME, "MsgFormat", TAGSDEFAULT);
- db_set_w(hContact, MODULENAME, "Status", Proto_GetStatus(MODULENAME));
+ g_plugin.setWString(hContact, "Nick", text);
+ g_plugin.setWString(hContact, "URL", url);
+ g_plugin.setWString(hContact, "Homepage", siteurl);
+ g_plugin.setByte(hContact, "CheckState", 1);
+ g_plugin.setDword(hContact, "UpdateTime", DEFAULT_UPDATE_TIME);
+ g_plugin.setWString(hContact, "MsgFormat", TAGSDEFAULT);
+ g_plugin.setWord(hContact, "Status", Proto_GetStatus(MODULENAME));
if (m_list != nullptr) {
int iItem = m_list->AddItem(text, -1);
@@ -701,35 +699,33 @@ bool CFeedEditor::OnInitDialog() m_list->GetItemText(m_iItem, 1, SelUrl, _countof(SelNick));
for (auto &hContact : Contacts(MODULENAME)) {
- ptrW dbNick(db_get_wsa(hContact, MODULENAME, "Nick"));
+ ptrW dbNick(g_plugin.getWStringA(hContact, "Nick"));
if ((dbNick == NULL) || (mir_wstrcmp(dbNick, SelNick) != 0))
continue;
- ptrW dbURL(db_get_wsa(hContact, MODULENAME, "URL"));
+ ptrW dbURL(g_plugin.getWStringA(hContact, "URL"));
if ((dbURL == NULL) || (mir_wstrcmp(dbURL, SelUrl) != 0))
continue;
m_hContact = hContact;
m_feedtitle.SetText(SelNick);
m_feedurl.SetText(SelUrl);
- m_checktime.SetInt(db_get_dw(hContact, MODULENAME, "UpdateTime", DEFAULT_UPDATE_TIME));
+ m_checktime.SetInt(g_plugin.getDword(hContact, "UpdateTime", DEFAULT_UPDATE_TIME));
- wchar_t *szMsgFormat = db_get_wsa(hContact, MODULENAME, "MsgFormat");
- if (szMsgFormat) {
+ ptrW szMsgFormat(g_plugin.getWStringA(hContact, "MsgFormat"));
+ if (szMsgFormat)
m_tagedit.SetText(szMsgFormat);
- mir_free(szMsgFormat);
- }
- if (db_get_b(hContact, MODULENAME, "UseAuth", 0)) {
+
+ if (g_plugin.getByte(hContact, "UseAuth", 0)) {
m_useauth.SetState(1);
m_login.Enable();
m_password.Enable();
- wchar_t *szLogin = db_get_wsa(hContact, MODULENAME, "Login");
- if (szLogin) {
+ ptrW szLogin(g_plugin.getWStringA(hContact, "Login"));
+ if (szLogin)
m_login.SetText(szLogin);
- mir_free(szLogin);
- }
- pass_ptrA pwd(db_get_sa(hContact, MODULENAME, "Password"));
+
+ pass_ptrA pwd(g_plugin.getStringA(hContact, "Password"));
m_password.SetTextA(pwd);
}
g_arFeeds.insert(this);
@@ -744,29 +740,27 @@ bool CFeedEditor::OnInitDialog() Utils_RestoreWindowPositionNoSize(m_hwnd, NULL, MODULENAME, "AddDlg");
}
else if (m_hContact != NULL) {
- ptrW dbNick(db_get_wsa(m_hContact, MODULENAME, "Nick"));
- ptrW dbURL(db_get_wsa(m_hContact, MODULENAME, "URL"));
+ ptrW dbNick(g_plugin.getWStringA(m_hContact, "Nick"));
+ ptrW dbURL(g_plugin.getWStringA(m_hContact, "URL"));
m_feedtitle.SetText(dbNick);
m_feedurl.SetText(dbURL);
- m_checktime.SetInt(db_get_dw(m_hContact, MODULENAME, "UpdateTime", DEFAULT_UPDATE_TIME));
+ m_checktime.SetInt(g_plugin.getDword(m_hContact, "UpdateTime", DEFAULT_UPDATE_TIME));
- wchar_t *szMsgFormat = db_get_wsa(m_hContact, MODULENAME, "MsgFormat");
- if (szMsgFormat) {
+ ptrW szMsgFormat(g_plugin.getWStringA(m_hContact, "MsgFormat"));
+ if (szMsgFormat)
m_tagedit.SetText(szMsgFormat);
- mir_free(szMsgFormat);
- }
- if (db_get_b(m_hContact, MODULENAME, "UseAuth", 0)) {
+
+ if (g_plugin.getByte(m_hContact, "UseAuth")) {
m_useauth.SetState(1);
m_login.Enable();
m_password.Enable();
- wchar_t *szLogin = db_get_wsa(m_hContact, MODULENAME, "Login");
- if (szLogin) {
+ ptrW szLogin(g_plugin.getWStringA(m_hContact, "Login"));
+ if (szLogin)
m_login.SetText(szLogin);
- mir_free(szLogin);
- }
- pass_ptrA pwd(db_get_sa(m_hContact, MODULENAME, "Password"));
+
+ pass_ptrA pwd(g_plugin.getStringA(m_hContact, "Password"));
m_password.SetTextA(pwd);
}
g_arFeeds.insert(this);
@@ -835,25 +829,24 @@ void CFeedEditor::OnOk(CCtrlBase*) if (m_iItem == -1 && m_hContact == NULL) {
hContact = db_add_contact();
Proto_AddToContact(hContact, MODULENAME);
- db_set_b(hContact, MODULENAME, "CheckState", 1);
+ g_plugin.setByte(hContact, "CheckState", 1);
}
- else
- hContact = m_hContact;
+ else hContact = m_hContact;
- db_set_ws(hContact, MODULENAME, "Nick", strfeedtitle);
- db_set_ws(hContact, MODULENAME, "URL", strfeedurl);
- db_set_dw(hContact, MODULENAME, "UpdateTime", (DWORD)m_checktime.GetInt());
- db_set_ws(hContact, MODULENAME, "MsgFormat", strtagedit);
- db_set_w(hContact, MODULENAME, "Status", Proto_GetStatus(MODULENAME));
+ g_plugin.setWString(hContact, "Nick", strfeedtitle);
+ g_plugin.setWString(hContact, "URL", strfeedurl);
+ g_plugin.setDword(hContact, "UpdateTime", m_checktime.GetInt());
+ g_plugin.setWString(hContact, "MsgFormat", strtagedit);
+ g_plugin.setWord(hContact, "Status", Proto_GetStatus(MODULENAME));
if (m_useauth.IsChecked()) {
- db_set_b(hContact, MODULENAME, "UseAuth", 1);
- db_set_ws(hContact, MODULENAME, "Login", m_login.GetText());
- db_set_s(hContact, MODULENAME, "Password", m_password.GetTextA());
+ g_plugin.setByte(hContact, "UseAuth", 1);
+ g_plugin.setWString(hContact, "Login", m_login.GetText());
+ g_plugin.setString(hContact, "Password", m_password.GetTextA());
}
else {
- db_unset(hContact, MODULENAME, "UseAuth");
- db_unset(hContact, MODULENAME, "Login");
- db_unset(hContact, MODULENAME, "Password");
+ g_plugin.delSetting(hContact, "UseAuth");
+ g_plugin.delSetting(hContact, "Login");
+ g_plugin.delSetting(hContact, "Password");
}
if (m_iItem == -1 && m_list != nullptr && m_hContact == NULL) {
@@ -886,17 +879,15 @@ void COptionsMain::UpdateList() {
for (auto &hContact : Contacts(MODULENAME)) {
UpdateListFlag = TRUE;
- wchar_t *ptszNick = db_get_wsa(hContact, MODULENAME, "Nick");
+ ptrW ptszNick(g_plugin.getWStringA(hContact, "Nick"));
if (ptszNick) {
int iItem = m_feeds.AddItem(ptszNick, -1);
- wchar_t *ptszURL = db_get_wsa(hContact, MODULENAME, "URL");
+ ptrW ptszURL(g_plugin.getWStringA(hContact, "URL"));
if (ptszURL) {
m_feeds.SetItem(iItem, 1, ptszURL);
- m_feeds.SetCheckState(iItem, db_get_b(hContact, MODULENAME, "CheckState", 1));
- mir_free(ptszURL);
+ m_feeds.SetCheckState(iItem, g_plugin.getByte(hContact, "CheckState", 1));
}
- mir_free(ptszNick);
}
}
UpdateListFlag = FALSE;
@@ -940,13 +931,13 @@ bool COptionsMain::OnInitDialog() bool COptionsMain::OnApply()
{
for (auto &hContact : Contacts(MODULENAME)) {
- ptrW dbNick(db_get_wsa(hContact, MODULENAME, "Nick"));
+ ptrW dbNick(g_plugin.getWStringA(hContact, "Nick"));
for (int i = 0; i < m_feeds.GetItemCount(); i++) {
wchar_t nick[MAX_PATH];
m_feeds.GetItemText(i, 0, nick, _countof(nick));
if (mir_wstrcmp(dbNick, nick) == 0)
{
- db_set_b(hContact, MODULENAME, "CheckState", m_feeds.GetCheckState(i));
+ g_plugin.setByte(hContact, "CheckState", m_feeds.GetCheckState(i));
if (!m_feeds.GetCheckState(i))
db_set_b(hContact, "CList", "Hidden", 1);
else
@@ -980,11 +971,11 @@ void COptionsMain::OnChangeButtonClick(CCtrlBase*) m_feeds.GetItemText(isel, 0, nick, _countof(nick));
m_feeds.GetItemText(isel, 1, url, _countof(url));
- ptrW dbNick(db_get_wsa(it->getContact(), MODULENAME, "Nick"));
+ ptrW dbNick(g_plugin.getWStringA(it->getContact(), "Nick"));
if ((dbNick == NULL) || (mir_wstrcmp(dbNick, nick) != 0))
continue;
- ptrW dbURL(db_get_wsa(it->getContact(), MODULENAME, "URL"));
+ ptrW dbURL(g_plugin.getWStringA(it->getContact(), "URL"));
if ((dbURL == NULL) || (mir_wstrcmp(dbURL, url) != 0))
continue;
@@ -1011,13 +1002,13 @@ void COptionsMain::OnDeleteButtonClick(CCtrlBase*) m_feeds.GetItemText(isel, 1, url, _countof(url));
for (auto &hContact : Contacts(MODULENAME)) {
- ptrW dbNick(db_get_wsa(hContact, MODULENAME, "Nick"));
+ ptrW dbNick(g_plugin.getWStringA(hContact, "Nick"));
if (dbNick == NULL)
break;
if (mir_wstrcmp(dbNick, nick))
continue;
- ptrW dbURL(db_get_wsa(hContact, MODULENAME, "URL"));
+ ptrW dbURL(g_plugin.getWStringA(hContact, "URL"));
if (dbURL == NULL)
break;
if (mir_wstrcmp(dbURL, url))
diff --git a/plugins/NewsAggregator/Src/Services.cpp b/plugins/NewsAggregator/Src/Services.cpp index 3dc61421d1..c0c5b02967 100644 --- a/plugins/NewsAggregator/Src/Services.cpp +++ b/plugins/NewsAggregator/Src/Services.cpp @@ -38,8 +38,8 @@ int NewsAggrInit(WPARAM, LPARAM) for (auto &hContact : Contacts(MODULENAME)) {
if (!g_plugin.getByte("StartupRetrieve", 1))
- db_set_dw(hContact, MODULENAME, "LastCheck", time(0));
- db_set_w(hContact, MODULENAME, "Status", ID_STATUS_ONLINE);
+ g_plugin.setDword(hContact, "LastCheck", time(0));
+ g_plugin.setWord(hContact, "Status", ID_STATUS_ONLINE);
}
NetlibInit();
@@ -97,7 +97,7 @@ INT_PTR NewsAggrSetStatus(WPARAM wp, LPARAM) g_nStatus = nStatus;
for (auto &hContact : Contacts(MODULENAME))
- db_set_w(hContact, MODULENAME, "Status", nStatus);
+ g_plugin.setWord(hContact, "Status", nStatus);
ProtoBroadcastAck(MODULENAME, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)nOldStatus, g_nStatus);
}
@@ -132,7 +132,7 @@ INT_PTR NewsAggrGetInfo(WPARAM, LPARAM lParam) INT_PTR CheckAllFeeds(WPARAM, LPARAM lParam)
{
for (auto &hContact : Contacts(MODULENAME)) {
- if (lParam && db_get_dw(hContact, MODULENAME, "UpdateTime", DEFAULT_UPDATE_TIME))
+ if (lParam && g_plugin.getDword(hContact, "UpdateTime", DEFAULT_UPDATE_TIME))
UpdateListAdd(hContact);
else if (!lParam)
UpdateListAdd(hContact);
@@ -207,17 +207,13 @@ INT_PTR NewsAggrGetAvatarInfo(WPARAM wParam, LPARAM lParam) // if GAIF_FORCE is set, we are updating the feed
// otherwise, cached avatar is used
- if ((wParam & GAIF_FORCE) && db_get_dw(pai->hContact, MODULENAME, "UpdateTime", DEFAULT_UPDATE_TIME))
+ if ((wParam & GAIF_FORCE) && g_plugin.getDword(pai->hContact, "UpdateTime", DEFAULT_UPDATE_TIME))
UpdateListAdd(pai->hContact);
if (g_plugin.getByte("AutoUpdate", 1) != 0 && !ThreadRunning)
mir_forkthread(UpdateThreadProc, (void *)TRUE);
- wchar_t *ptszImageURL = db_get_wsa(pai->hContact, MODULENAME, "ImageURL");
- if(ptszImageURL == nullptr)
- return GAIR_NOAVATAR;
-
- mir_free(ptszImageURL);
- return GAIR_WAITFOR;
+ ptrW ptszImageURL(g_plugin.getWStringA(pai->hContact, "ImageURL"));
+ return (ptszImageURL == nullptr) ? GAIR_NOAVATAR : GAIR_WAITFOR;
}
INT_PTR NewsAggrRecvMessage(WPARAM, LPARAM lParam)
diff --git a/plugins/NewsAggregator/Src/Update.cpp b/plugins/NewsAggregator/Src/Update.cpp index cde3ef2686..8bfe23de8c 100644 --- a/plugins/NewsAggregator/Src/Update.cpp +++ b/plugins/NewsAggregator/Src/Update.cpp @@ -31,9 +31,9 @@ void CALLBACK timerProc(HWND, UINT, UINT_PTR, DWORD) if (!ThreadRunning && !Miranda_IsTerminated()) {
bool HaveUpdates = FALSE;
for (auto &hContact : Contacts(MODULENAME)) {
- if (db_get_dw(hContact, MODULENAME, "UpdateTime", DEFAULT_UPDATE_TIME)) {
- double diff = difftime(time(0), (time_t)db_get_dw(hContact, MODULENAME, "LastCheck", 0));
- if (g_plugin.getByte("AutoUpdate", 1) != 0 && diff >= db_get_dw(hContact, MODULENAME, "UpdateTime", DEFAULT_UPDATE_TIME) * 60) {
+ if (g_plugin.getDword(hContact, "UpdateTime", DEFAULT_UPDATE_TIME)) {
+ double diff = difftime(time(0), (time_t)g_plugin.getDword(hContact, "LastCheck", 0));
+ if (g_plugin.getByte("AutoUpdate", 1) != 0 && diff >= g_plugin.getDword(hContact, "UpdateTime", DEFAULT_UPDATE_TIME) * 60) {
UpdateListAdd(hContact);
HaveUpdates = TRUE;
}
diff --git a/plugins/NewsAggregator/Src/Utils.cpp b/plugins/NewsAggregator/Src/Utils.cpp index 4ff53e658d..c18fe3fe54 100644 --- a/plugins/NewsAggregator/Src/Utils.cpp +++ b/plugins/NewsAggregator/Src/Utils.cpp @@ -72,7 +72,7 @@ void GetNewsData(wchar_t *tszUrl, char **szData, MCONTACT hContact, CFeedEditor nlhr.headers[3].szName = "Connection";
nlhr.headers[3].szValue = "close";
char auth[256];
- if (db_get_b(hContact, MODULENAME, "UseAuth", 0) || (pEditDlg && pEditDlg->m_useauth.IsChecked()) /*IsDlgButtonChecked(hwndDlg, IDC_USEAUTH)*/) {
+ if (g_plugin.getByte(hContact, "UseAuth", 0) || (pEditDlg && pEditDlg->m_useauth.IsChecked()) /*IsDlgButtonChecked(hwndDlg, IDC_USEAUTH)*/) {
nlhr.headersCount++;
nlhr.headers[4].szName = "Authorization";
@@ -430,7 +430,7 @@ LPCTSTR ClearText(CMStringW &result, const wchar_t *message) MCONTACT GetContactByNick(const wchar_t *nick)
{
for (auto &hContact : Contacts(MODULENAME)) {
- ptrW contactNick(::db_get_wsa(hContact, MODULENAME, "Nick"));
+ ptrW contactNick(g_plugin.getWStringA(hContact, "Nick"));
if (!mir_wstrcmpi(contactNick, nick))
return hContact;
}
@@ -440,7 +440,7 @@ MCONTACT GetContactByNick(const wchar_t *nick) MCONTACT GetContactByURL(const wchar_t *url)
{
for (auto &hContact : Contacts(MODULENAME)) {
- ptrW contactURL(::db_get_wsa(hContact, MODULENAME, "URL"));
+ ptrW contactURL(g_plugin.getWStringA(hContact, "URL"));
if (!mir_wstrcmpi(contactURL, url))
return hContact;
}
|