diff options
author | George Hazan <ghazan@miranda.im> | 2018-05-20 15:08:48 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-05-20 15:08:48 +0300 |
commit | 8a74e7495ce5ad39de4f5c25121a84d35df90c36 (patch) | |
tree | 03e5b4870f09a3163306740c2eebee47bc15b042 /plugins/NewsAggregator | |
parent | c5bf7d6123dd1c3b82ccb8fdb1b068077e9d56d4 (diff) |
CMPlugin to receive a reference to PLUGININFOEX
Diffstat (limited to 'plugins/NewsAggregator')
-rw-r--r-- | plugins/NewsAggregator/Src/Authentication.cpp | 16 | ||||
-rw-r--r-- | plugins/NewsAggregator/Src/CheckFeed.cpp | 90 | ||||
-rw-r--r-- | plugins/NewsAggregator/Src/Icons.cpp | 4 | ||||
-rw-r--r-- | plugins/NewsAggregator/Src/Menus.cpp | 8 | ||||
-rw-r--r-- | plugins/NewsAggregator/Src/NewsAggregator.cpp | 23 | ||||
-rw-r--r-- | plugins/NewsAggregator/Src/Options.cpp | 124 | ||||
-rw-r--r-- | plugins/NewsAggregator/Src/Services.cpp | 38 | ||||
-rw-r--r-- | plugins/NewsAggregator/Src/Update.cpp | 12 | ||||
-rw-r--r-- | plugins/NewsAggregator/Src/Utils.cpp | 14 | ||||
-rw-r--r-- | plugins/NewsAggregator/Src/stdafx.h | 9 |
10 files changed, 170 insertions, 168 deletions
diff --git a/plugins/NewsAggregator/Src/Authentication.cpp b/plugins/NewsAggregator/Src/Authentication.cpp index 318f8ea0a3..cc02d91bd9 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, MODULE, "UseAuth", 0)) {
- tlogin = db_get_wsa(hContact, MODULE, "Login");
- tpass = db_get_wsa(hContact, MODULE, "Password");
+ if (hContact && db_get_b(hContact, MODULENAME, "UseAuth", 0)) {
+ tlogin = db_get_wsa(hContact, MODULENAME, "Login");
+ tpass = db_get_wsa(hContact, MODULENAME, "Password");
}
else if (pDlg && pDlg->m_useauth.IsChecked()) {
tlogin = pDlg->m_login.GetText();
@@ -65,13 +65,13 @@ void CAuthRequest::OnInitDialog() }
}
else if (m_hContact) {
- wchar_t *ptszNick = db_get_wsa(m_hContact, MODULE, "Nick");
+ wchar_t *ptszNick = db_get_wsa(m_hContact, MODULENAME, "Nick");
if (ptszNick) {
m_feedname.SetText(ptszNick);
mir_free(ptszNick);
}
else {
- wchar_t *ptszURL = db_get_wsa(m_hContact, MODULE, "URL");
+ wchar_t *ptszURL = db_get_wsa(m_hContact, MODULENAME, "URL");
if (ptszURL) {
m_feedname.SetText(ptszURL);
mir_free(ptszURL);
@@ -100,9 +100,9 @@ void CAuthRequest::OnOk(CCtrlBase*) m_pDlg->m_password.SetTextA(strfeedpassword);
}
else if (m_hContact) {
- db_set_b(m_hContact, MODULE, "UseAuth", 1);
- db_set_ws(m_hContact, MODULE, "Login", strfeedusername);
- db_set_s(m_hContact, MODULE, "Password", strfeedpassword);
+ db_set_b(m_hContact, MODULENAME, "UseAuth", 1);
+ db_set_ws(m_hContact, MODULENAME, "Login", strfeedusername);
+ db_set_s(m_hContact, MODULENAME, "Password", strfeedpassword);
}
}
diff --git a/plugins/NewsAggregator/Src/CheckFeed.cpp b/plugins/NewsAggregator/Src/CheckFeed.cpp index 559b52d3d9..fd01491274 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, MODULE, "MsgFormat");
+ CMStringW message = db_get_wsa(hContact, MODULENAME, "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, MODULE, "CheckState", 1) != 0)
+ if (!db_get_b(hContact, MODULENAME, "CheckState", 1) != 0)
return;
- wchar_t *szURL = db_get_wsa(hContact, MODULE, "URL");
+ wchar_t *szURL = db_get_wsa(hContact, MODULENAME, "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, MODULE, "MirVer", ver);
+ db_set_ws(hContact, MODULENAME, "MirVer", ver);
break;
}
}
}
else if (isAtom)
- db_set_ws(hContact, MODULE, "MirVer", L"RSS 1.0");
+ db_set_ws(hContact, MODULENAME, "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, MODULE, "FirstName", ClearText(szValue, szChildText));
+ db_set_ws(hContact, MODULENAME, "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, MODULE, "Homepage", ClearText(szValue, szChildText));
+ db_set_ws(hContact, MODULENAME, "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, MODULE, "About", szValue);
+ db_set_ws(hContact, MODULENAME, "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, MODULE, "Language1", ClearText(szValue, szChildText));
+ db_set_ws(hContact, MODULENAME, "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, MODULE, "e-mail", ClearText(szValue, szChildText));
+ db_set_ws(hContact, MODULENAME, "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, MODULE, "Interest0Text", ClearText(szValue, szChildText));
+ db_set_ws(hContact, MODULENAME, "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, MODULE, "ImageURL", url);
+ db_set_ws(hContact, MODULENAME, "ImageURL", url);
PROTO_AVATAR_INFORMATION ai = { 0 };
ai.hContact = hContact;
- wchar_t *szNick = db_get_wsa(hContact, MODULE, "Nick");
+ wchar_t *szNick = db_get_wsa(hContact, MODULENAME, "Nick");
if (szNick) {
wchar_t *ext = wcsrchr((wchar_t *)url, '.') + 1;
ai.format = ProtoGetAvatarFormat(url);
@@ -371,10 +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, MODULE, "ImagePath", ai.filename);
- ProtoBroadcastAck(MODULE, hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&ai, NULL);
+ db_set_ws(hContact, MODULENAME, "ImagePath", ai.filename);
+ ProtoBroadcastAck(MODULENAME, hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&ai, NULL);
}
- else ProtoBroadcastAck(MODULE, hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, (HANDLE)&ai, NULL);
+ else ProtoBroadcastAck(MODULENAME, hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, (HANDLE)&ai, NULL);
mir_free(szNick);
break;
}
@@ -393,9 +393,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, MODULE, "LastCheck", 0));
+ double deltacheck = difftime(time(0), (time_t)db_get_dw(hContact, MODULENAME, "LastCheck", 0));
if (deltaupd - deltacheck >= 0) {
- db_set_dw(hContact, MODULE, "LastCheck", (DWORD)time(0));
+ db_set_dw(hContact, MODULENAME, "LastCheck", (DWORD)time(0));
xmlDestroyNode(hXml);
return;
}
@@ -448,14 +448,14 @@ void CheckCurrentFeed(MCONTACT hContact) }
}
else if (!mir_wstrcmpi(szNodeName, L"feed")) {
- db_set_ws(hContact, MODULE, "MirVer", L"Atom 3");
+ db_set_ws(hContact, MODULENAME, "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, MODULE, "FirstName", ClearText(szValue, szChildText));
+ db_set_ws(hContact, MODULENAME, "FirstName", ClearText(szValue, szChildText));
}
else if (!mir_wstrcmpi(szChildName, L"link")) {
for (int x = 0; x < xmlGetAttrCount(child); x++) {
@@ -464,27 +464,27 @@ void CheckCurrentFeed(MCONTACT hContact) break;
if (!mir_wstrcmpi(xmlGetAttrName(child, x), L"href"))
- db_set_ws(hContact, MODULE, "Homepage", xmlGetAttrValue(child, xmlGetAttrName(child, x)));
+ db_set_ws(hContact, MODULENAME, "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, MODULE, "About", szValue);
+ db_set_ws(hContact, MODULENAME, "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, MODULE, "Language1", ClearText(szValue, szChildText));
+ db_set_ws(hContact, MODULENAME, "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, MODULE, "e-mail", xmlGetText(authorval));
+ db_set_ws(hContact, MODULENAME, "e-mail", xmlGetText(authorval));
break;
}
}
@@ -492,16 +492,16 @@ void CheckCurrentFeed(MCONTACT hContact) else if (!mir_wstrcmpi(szChildName, L"category")) {
LPCTSTR szChildText = xmlGetText(child);
if (szChildText)
- db_set_ws(hContact, MODULE, "Interest0Text", ClearText(szValue, szChildText));
+ db_set_ws(hContact, MODULENAME, "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, MODULE, "ImageURL", url);
+ db_set_ws(hContact, MODULENAME, "ImageURL", url);
- ptrW szNick(db_get_wsa(hContact, MODULE, "Nick"));
+ ptrW szNick(db_get_wsa(hContact, MODULENAME, "Nick"));
if (szNick) {
PROTO_AVATAR_INFORMATION ai = { 0 };
ai.hContact = hContact;
@@ -511,10 +511,10 @@ 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, MODULE, "ImagePath", ai.filename);
- ProtoBroadcastAck(MODULE, hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&ai, NULL);
+ db_set_ws(hContact, MODULENAME, "ImagePath", ai.filename);
+ ProtoBroadcastAck(MODULENAME, hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&ai, NULL);
}
- else ProtoBroadcastAck(MODULE, hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, (HANDLE)&ai, NULL);
+ else ProtoBroadcastAck(MODULENAME, hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, (HANDLE)&ai, NULL);
break;
}
}
@@ -526,9 +526,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, MODULE, "LastCheck", 0));
+ double deltacheck = difftime(time(0), (time_t)db_get_dw(hContact, MODULENAME, "LastCheck", 0));
if (deltaupd - deltacheck >= 0) {
- db_set_dw(hContact, MODULE, "LastCheck", (DWORD)time(0));
+ db_set_dw(hContact, MODULENAME, "LastCheck", (DWORD)time(0));
xmlDestroyNode(hXml);
return;
}
@@ -601,15 +601,15 @@ void CheckCurrentFeed(MCONTACT hContact) xmlDestroyNode(hXml);
}
}
- db_set_dw(hContact, MODULE, "LastCheck", (DWORD)time(0));
+ db_set_dw(hContact, MODULENAME, "LastCheck", (DWORD)time(0));
}
void CheckCurrentFeedAvatar(MCONTACT hContact)
{
- if (!db_get_b(hContact, MODULE, "CheckState", 1))
+ if (!db_get_b(hContact, MODULENAME, "CheckState", 1))
return;
- wchar_t *szURL = db_get_wsa(hContact, MODULE, "URL");
+ wchar_t *szURL = db_get_wsa(hContact, MODULENAME, "URL");
if (szURL == nullptr)
return;
@@ -643,12 +643,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, MODULE, "ImageURL", url);
+ db_set_ws(hContact, MODULENAME, "ImageURL", url);
PROTO_AVATAR_INFORMATION ai = { 0 };
ai.hContact = hContact;
- wchar_t *szNick = db_get_wsa(hContact, MODULE, "Nick");
+ wchar_t *szNick = db_get_wsa(hContact, MODULENAME, "Nick");
if (szNick) {
wchar_t *ext = wcsrchr((wchar_t *)url, '.') + 1;
ai.format = ProtoGetAvatarFormat(ext);
@@ -656,10 +656,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, MODULE, "ImagePath", ai.filename);
- ProtoBroadcastAck(MODULE, hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&ai, NULL);
+ db_set_ws(hContact, MODULENAME, "ImagePath", ai.filename);
+ ProtoBroadcastAck(MODULENAME, hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&ai, NULL);
}
- else ProtoBroadcastAck(MODULE, hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, (HANDLE)&ai, NULL);
+ else ProtoBroadcastAck(MODULENAME, hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, (HANDLE)&ai, NULL);
mir_free(szNick);
break;
}
@@ -676,9 +676,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, MODULE, "ImageURL", url);
+ db_set_ws(hContact, MODULENAME, "ImageURL", url);
- ptrW szNick(db_get_wsa(hContact, MODULE, "Nick"));
+ ptrW szNick(db_get_wsa(hContact, MODULENAME, "Nick"));
if (szNick) {
PROTO_AVATAR_INFORMATION ai = { 0 };
ai.hContact = hContact;
@@ -689,10 +689,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, MODULE, "ImagePath", ai.filename);
- ProtoBroadcastAck(MODULE, hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&ai, NULL);
+ db_set_ws(hContact, MODULENAME, "ImagePath", ai.filename);
+ ProtoBroadcastAck(MODULENAME, hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&ai, NULL);
}
- else ProtoBroadcastAck(MODULE, hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, (HANDLE)&ai, NULL);
+ else ProtoBroadcastAck(MODULENAME, hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, (HANDLE)&ai, NULL);
break;
}
}
diff --git a/plugins/NewsAggregator/Src/Icons.cpp b/plugins/NewsAggregator/Src/Icons.cpp index 2c6ff8d049..4ceea9c42d 100644 --- a/plugins/NewsAggregator/Src/Icons.cpp +++ b/plugins/NewsAggregator/Src/Icons.cpp @@ -33,13 +33,13 @@ static IconItem iconList[] = void InitIcons()
{
- g_plugin.registerIcon(LPGEN("News Aggregator"), iconList, MODULE);
+ g_plugin.registerIcon(LPGEN("News Aggregator"), iconList, MODULENAME);
}
HICON LoadIconEx(const char *name, bool big)
{
char szSettingName[100];
- mir_snprintf(szSettingName, "%s_%s", MODULE, name);
+ mir_snprintf(szSettingName, "%s_%s", MODULENAME, name);
return IcoLib_GetIcon(szSettingName, big);
}
diff --git a/plugins/NewsAggregator/Src/Menus.cpp b/plugins/NewsAggregator/Src/Menus.cpp index 73128cf5be..7f6a73f77f 100644 --- a/plugins/NewsAggregator/Src/Menus.cpp +++ b/plugins/NewsAggregator/Src/Menus.cpp @@ -30,7 +30,7 @@ void InitMenu() SET_UID(mi, 0x3ec91864, 0xefa7, 0x4994, 0xb7, 0x75, 0x6c, 0x96, 0xcb, 0x29, 0x2f, 0x93);
mi.position = 10100001;
- if (db_get_b(NULL, MODULE, "AutoUpdate", 1))
+ if (db_get_b(NULL, MODULENAME, "AutoUpdate", 1))
mi.name.w = LPGENW("Auto Update Enabled");
else
mi.name.w = LPGENW("Auto Update Disabled");
@@ -72,12 +72,12 @@ void InitMenu() mi.hIcolibItem = GetIconHandle("checkfeed");
mi.name.w = LPGENW("Check feed");
mi.pszService = MS_NEWSAGGREGATOR_CHECKFEED;
- hService2[5] = Menu_AddContactMenuItem(&mi, MODULE);
+ hService2[5] = Menu_AddContactMenuItem(&mi, MODULENAME);
SET_UID(mi, 0x41a70fbc, 0x9241, 0x44c0, 0x90, 0x90, 0x87, 0xd2, 0xc5, 0x9f, 0xc9, 0xac);
mi.name.w = LPGENW("Change feed");
mi.pszService = MS_NEWSAGGREGATOR_CHANGEFEED;
- hService2[6] = Menu_AddContactMenuItem(&mi, MODULE);
+ hService2[6] = Menu_AddContactMenuItem(&mi, MODULENAME);
- Menu_ModifyItem(hService2[0], nullptr, GetIconHandle(db_get_b(NULL, MODULE, "AutoUpdate", 1) ? "enabled" : "disabled"));
+ Menu_ModifyItem(hService2[0], nullptr, GetIconHandle(db_get_b(NULL, MODULENAME, "AutoUpdate", 1) ? "enabled" : "disabled"));
}
diff --git a/plugins/NewsAggregator/Src/NewsAggregator.cpp b/plugins/NewsAggregator/Src/NewsAggregator.cpp index 24fa21e9b0..6bf1394e3b 100644 --- a/plugins/NewsAggregator/Src/NewsAggregator.cpp +++ b/plugins/NewsAggregator/Src/NewsAggregator.cpp @@ -42,6 +42,13 @@ PLUGININFOEX pluginInfoEx = { {0x56cc3f29, 0xccbf, 0x4546, {0xa8, 0xba, 0x98, 0x56, 0x24, 0x8a, 0x41, 0x2a}}
};
+CMPlugin::CMPlugin() :
+ PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
+{
+ RegisterProtocol(PROTOTYPE_VIRTUAL);
+ SetUniqueId("URL");
+}
+
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfoEx;
@@ -68,14 +75,14 @@ extern "C" __declspec(dllexport) int Load(void) hUpdateMutex = CreateMutex(nullptr, FALSE, nullptr);
- CreateProtoServiceFunction(MODULE, PS_GETNAME, NewsAggrGetName);
- CreateProtoServiceFunction(MODULE, PS_GETCAPS, NewsAggrGetCaps);
- CreateProtoServiceFunction(MODULE, PS_SETSTATUS, NewsAggrSetStatus);
- CreateProtoServiceFunction(MODULE, PS_GETSTATUS, NewsAggrGetStatus);
- CreateProtoServiceFunction(MODULE, PS_LOADICON, NewsAggrLoadIcon);
- CreateProtoServiceFunction(MODULE, PSS_GETINFO, NewsAggrGetInfo);
- CreateProtoServiceFunction(MODULE, PS_GETAVATARINFO, NewsAggrGetAvatarInfo);
- CreateProtoServiceFunction(MODULE, PSR_MESSAGE, NewsAggrRecvMessage);
+ CreateProtoServiceFunction(MODULENAME, PS_GETNAME, NewsAggrGetName);
+ CreateProtoServiceFunction(MODULENAME, PS_GETCAPS, NewsAggrGetCaps);
+ CreateProtoServiceFunction(MODULENAME, PS_SETSTATUS, NewsAggrSetStatus);
+ CreateProtoServiceFunction(MODULENAME, PS_GETSTATUS, NewsAggrGetStatus);
+ CreateProtoServiceFunction(MODULENAME, PS_LOADICON, NewsAggrLoadIcon);
+ CreateProtoServiceFunction(MODULENAME, PSS_GETINFO, NewsAggrGetInfo);
+ CreateProtoServiceFunction(MODULENAME, PS_GETAVATARINFO, NewsAggrGetAvatarInfo);
+ CreateProtoServiceFunction(MODULENAME, PSR_MESSAGE, NewsAggrRecvMessage);
CreateServiceFunction(MS_NEWSAGGREGATOR_CHECKALLFEEDS, CheckAllFeeds);
CreateServiceFunction(MS_NEWSAGGREGATOR_ADDFEED, AddFeed);
diff --git a/plugins/NewsAggregator/Src/Options.cpp b/plugins/NewsAggregator/Src/Options.cpp index b51360f21e..86ce209c22 100644 --- a/plugins/NewsAggregator/Src/Options.cpp +++ b/plugins/NewsAggregator/Src/Options.cpp @@ -38,9 +38,9 @@ CExportFeed::CExportFeed() void CExportFeed::OnInitDialog()
{
- Utils_RestoreWindowPositionNoSize(m_hwnd, NULL, MODULE, "ExportDlg");
- for (auto &hContact : Contacts(MODULE)) {
- wchar_t *message = db_get_wsa(hContact, MODULE, "Nick");
+ Utils_RestoreWindowPositionNoSize(m_hwnd, NULL, MODULENAME, "ExportDlg");
+ for (auto &hContact : Contacts(MODULENAME)) {
+ wchar_t *message = db_get_wsa(hContact, MODULENAME, "Nick");
if (message != nullptr) {
m_feedslist.AddString(message);
mir_free(message);
@@ -200,9 +200,9 @@ void CExportFeed::OnOk(CCtrlBase*) m_feedsexportlist.GetItemText(i, item, _countof(item));
MCONTACT hContact = GetContactByNick(item);
wchar_t
- *title = db_get_wsa(hContact, MODULE, "Nick"),
- *url = db_get_wsa(hContact, MODULE, "URL"),
- *siteurl = db_get_wsa(hContact, MODULE, "Homepage"),
+ *title = db_get_wsa(hContact, MODULENAME, "Nick"),
+ *url = db_get_wsa(hContact, MODULENAME, "URL"),
+ *siteurl = db_get_wsa(hContact, MODULENAME, "Homepage"),
*group = db_get_wsa(hContact, "CList", "Group");
HXML elem = header;
@@ -245,7 +245,7 @@ void CExportFeed::OnOk(CCtrlBase*) void CExportFeed::OnClose()
{
- Utils_SaveWindowPosition(m_hwnd, NULL, MODULE, "ExportDlg");
+ Utils_SaveWindowPosition(m_hwnd, NULL, MODULENAME, "ExportDlg");
if (pExportDialog)
pExportDialog = nullptr;
}
@@ -272,7 +272,7 @@ CImportFeed::CImportFeed(CCtrlListView *m_feeds) void CImportFeed::OnInitDialog()
{
- Utils_RestoreWindowPositionNoSize(m_hwnd, NULL, MODULE, "ImportDlg");
+ Utils_RestoreWindowPositionNoSize(m_hwnd, NULL, MODULENAME, "ImportDlg");
m_removefeed.Disable();
m_removeallfeeds.Disable();
m_ok.Disable();
@@ -599,14 +599,14 @@ void CImportFeed::OnOk(CCtrlBase*) }
MCONTACT hContact = db_add_contact();
- Proto_AddToContact(hContact, MODULE);
- db_set_ws(hContact, MODULE, "Nick", text);
- db_set_ws(hContact, MODULE, "URL", url);
- db_set_ws(hContact, MODULE, "Homepage", siteurl);
- db_set_b(hContact, MODULE, "CheckState", 1);
- db_set_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME);
- db_set_ws(hContact, MODULE, "MsgFormat", TAGSDEFAULT);
- db_set_w(hContact, MODULE, "Status", Proto_GetStatus(MODULE));
+ 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));
if (m_list != nullptr) {
int iItem = m_list->AddItem(text, -1);
@@ -655,7 +655,7 @@ void CImportFeed::OnOk(CCtrlBase*) void CImportFeed::OnClose()
{
- Utils_SaveWindowPosition(m_hwnd, NULL, MODULE, "ImportDlg");
+ Utils_SaveWindowPosition(m_hwnd, NULL, MODULENAME, "ImportDlg");
if (pImportDialog)
pImportDialog = nullptr;
}
@@ -692,40 +692,40 @@ void CFeedEditor::OnInitDialog() m_list->GetItemText(m_iItem, 0, SelNick, _countof(SelNick));
m_list->GetItemText(m_iItem, 1, SelUrl, _countof(SelNick));
- for (auto &hContact : Contacts(MODULE)) {
- ptrW dbNick(db_get_wsa(hContact, MODULE, "Nick"));
+ for (auto &hContact : Contacts(MODULENAME)) {
+ ptrW dbNick(db_get_wsa(hContact, MODULENAME, "Nick"));
if ((dbNick == NULL) || (mir_wstrcmp(dbNick, SelNick) != 0))
continue;
- ptrW dbURL(db_get_wsa(hContact, MODULE, "URL"));
+ ptrW dbURL(db_get_wsa(hContact, MODULENAME, "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, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME));
+ m_checktime.SetInt(db_get_dw(hContact, MODULENAME, "UpdateTime", DEFAULT_UPDATE_TIME));
- wchar_t *szMsgFormat = db_get_wsa(hContact, MODULE, "MsgFormat");
+ wchar_t *szMsgFormat = db_get_wsa(hContact, MODULENAME, "MsgFormat");
if (szMsgFormat) {
m_tagedit.SetText(szMsgFormat);
mir_free(szMsgFormat);
}
- if (db_get_b(hContact, MODULE, "UseAuth", 0)) {
+ if (db_get_b(hContact, MODULENAME, "UseAuth", 0)) {
m_useauth.SetState(1);
m_login.Enable();
m_password.Enable();
- wchar_t *szLogin = db_get_wsa(hContact, MODULE, "Login");
+ wchar_t *szLogin = db_get_wsa(hContact, MODULENAME, "Login");
if (szLogin) {
m_login.SetText(szLogin);
mir_free(szLogin);
}
- pass_ptrA pwd(db_get_sa(hContact, MODULE, "Password"));
+ pass_ptrA pwd(db_get_sa(hContact, MODULENAME, "Password"));
m_password.SetTextA(pwd);
}
g_arFeeds.insert(this);
- Utils_RestoreWindowPositionNoSize(m_hwnd, hContact, MODULE, "ChangeDlg");
+ Utils_RestoreWindowPositionNoSize(m_hwnd, hContact, MODULENAME, "ChangeDlg");
break;
}
}
@@ -733,36 +733,36 @@ void CFeedEditor::OnInitDialog() m_feedurl.SetText(L"http://");
m_tagedit.SetText(TAGSDEFAULT);
m_checktime.SetInt(DEFAULT_UPDATE_TIME);
- Utils_RestoreWindowPositionNoSize(m_hwnd, NULL, MODULE, "AddDlg");
+ Utils_RestoreWindowPositionNoSize(m_hwnd, NULL, MODULENAME, "AddDlg");
}
else if (m_hContact != NULL) {
- ptrW dbNick(db_get_wsa(m_hContact, MODULE, "Nick"));
- ptrW dbURL(db_get_wsa(m_hContact, MODULE, "URL"));
+ ptrW dbNick(db_get_wsa(m_hContact, MODULENAME, "Nick"));
+ ptrW dbURL(db_get_wsa(m_hContact, MODULENAME, "URL"));
m_feedtitle.SetText(dbNick);
m_feedurl.SetText(dbURL);
- m_checktime.SetInt(db_get_dw(m_hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME));
+ m_checktime.SetInt(db_get_dw(m_hContact, MODULENAME, "UpdateTime", DEFAULT_UPDATE_TIME));
- wchar_t *szMsgFormat = db_get_wsa(m_hContact, MODULE, "MsgFormat");
+ wchar_t *szMsgFormat = db_get_wsa(m_hContact, MODULENAME, "MsgFormat");
if (szMsgFormat) {
m_tagedit.SetText(szMsgFormat);
mir_free(szMsgFormat);
}
- if (db_get_b(m_hContact, MODULE, "UseAuth", 0)) {
+ if (db_get_b(m_hContact, MODULENAME, "UseAuth", 0)) {
m_useauth.SetState(1);
m_login.Enable();
m_password.Enable();
- wchar_t *szLogin = db_get_wsa(m_hContact, MODULE, "Login");
+ wchar_t *szLogin = db_get_wsa(m_hContact, MODULENAME, "Login");
if (szLogin) {
m_login.SetText(szLogin);
mir_free(szLogin);
}
- pass_ptrA pwd(db_get_sa(m_hContact, MODULE, "Password"));
+ pass_ptrA pwd(db_get_sa(m_hContact, MODULENAME, "Password"));
m_password.SetTextA(pwd);
}
g_arFeeds.insert(this);
- Utils_RestoreWindowPositionNoSize(m_hwnd, m_hContact, MODULE, "ChangeDlg");
+ Utils_RestoreWindowPositionNoSize(m_hwnd, m_hContact, MODULENAME, "ChangeDlg");
}
}
@@ -825,26 +825,26 @@ void CFeedEditor::OnOk(CCtrlBase*) MCONTACT hContact;
if (m_iItem == -1 && m_hContact == NULL) {
hContact = db_add_contact();
- Proto_AddToContact(hContact, MODULE);
- db_set_b(hContact, MODULE, "CheckState", 1);
+ Proto_AddToContact(hContact, MODULENAME);
+ db_set_b(hContact, MODULENAME, "CheckState", 1);
}
else
hContact = m_hContact;
- db_set_ws(hContact, MODULE, "Nick", strfeedtitle);
- db_set_ws(hContact, MODULE, "URL", strfeedurl);
- db_set_dw(hContact, MODULE, "UpdateTime", (DWORD)m_checktime.GetInt());
- db_set_ws(hContact, MODULE, "MsgFormat", strtagedit);
- db_set_w(hContact, MODULE, "Status", Proto_GetStatus(MODULE));
+ 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));
if (m_useauth.IsChecked()) {
- db_set_b(hContact, MODULE, "UseAuth", 1);
- db_set_ws(hContact, MODULE, "Login", m_login.GetText());
- db_set_s(hContact, MODULE, "Password", m_password.GetTextA());
+ 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());
}
else {
- db_unset(hContact, MODULE, "UseAuth");
- db_unset(hContact, MODULE, "Login");
- db_unset(hContact, MODULE, "Password");
+ db_unset(hContact, MODULENAME, "UseAuth");
+ db_unset(hContact, MODULENAME, "Login");
+ db_unset(hContact, MODULENAME, "Password");
}
if (m_iItem == -1 && m_list != nullptr && m_hContact == NULL) {
@@ -861,7 +861,7 @@ void CFeedEditor::OnOk(CCtrlBase*) void CFeedEditor::OnClose()
{
g_arFeeds.remove(this);
- Utils_SaveWindowPosition(m_hwnd, NULL, MODULE, m_iItem == -1 ? "AddDlg" : "ChangeDlg");
+ Utils_SaveWindowPosition(m_hwnd, NULL, MODULENAME, m_iItem == -1 ? "AddDlg" : "ChangeDlg");
if (pAddFeedDialog == this)
pAddFeedDialog = nullptr;
}
@@ -874,16 +874,16 @@ void CFeedEditor::OnUseAuth(CCtrlBase*) void COptionsMain::UpdateList()
{
- for (auto &hContact : Contacts(MODULE)) {
+ for (auto &hContact : Contacts(MODULENAME)) {
UpdateListFlag = TRUE;
- wchar_t *ptszNick = db_get_wsa(hContact, MODULE, "Nick");
+ wchar_t *ptszNick = db_get_wsa(hContact, MODULENAME, "Nick");
if (ptszNick) {
int iItem = m_feeds.AddItem(ptszNick, -1);
- wchar_t *ptszURL = db_get_wsa(hContact, MODULE, "URL");
+ wchar_t *ptszURL = db_get_wsa(hContact, MODULENAME, "URL");
if (ptszURL) {
m_feeds.SetItem(iItem, 1, ptszURL);
- m_feeds.SetCheckState(iItem, db_get_b(hContact, MODULE, "CheckState", 1));
+ m_feeds.SetCheckState(iItem, db_get_b(hContact, MODULENAME, "CheckState", 1));
mir_free(ptszURL);
}
mir_free(ptszNick);
@@ -893,7 +893,7 @@ void COptionsMain::UpdateList() }
COptionsMain::COptionsMain()
- : CPluginDlgBase(g_plugin, IDD_OPTIONS, MODULE),
+ : CPluginDlgBase(g_plugin, IDD_OPTIONS, MODULENAME),
m_feeds(this, IDC_FEEDLIST),
m_add(this, IDC_ADD),
m_change(this, IDC_CHANGE),
@@ -928,14 +928,14 @@ void COptionsMain::OnInitDialog() void COptionsMain::OnApply()
{
- for (auto &hContact : Contacts(MODULE)) {
- ptrW dbNick(db_get_wsa(hContact, MODULE, "Nick"));
+ for (auto &hContact : Contacts(MODULENAME)) {
+ ptrW dbNick(db_get_wsa(hContact, MODULENAME, "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, MODULE, "CheckState", m_feeds.GetCheckState(i));
+ db_set_b(hContact, MODULENAME, "CheckState", m_feeds.GetCheckState(i));
if (!m_feeds.GetCheckState(i))
db_set_b(hContact, "CList", "Hidden", 1);
else
@@ -968,11 +968,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(), MODULE, "Nick"));
+ ptrW dbNick(db_get_wsa(it->getContact(), MODULENAME, "Nick"));
if ((dbNick == NULL) || (mir_wstrcmp(dbNick, nick) != 0))
continue;
- ptrW dbURL(db_get_wsa(it->getContact(), MODULE, "URL"));
+ ptrW dbURL(db_get_wsa(it->getContact(), MODULENAME, "URL"));
if ((dbURL == NULL) || (mir_wstrcmp(dbURL, url) != 0))
continue;
@@ -998,14 +998,14 @@ void COptionsMain::OnDeleteButtonClick(CCtrlBase*) m_feeds.GetItemText(isel, 0, nick, _countof(nick));
m_feeds.GetItemText(isel, 1, url, _countof(url));
- for (auto &hContact : Contacts(MODULE)) {
- ptrW dbNick(db_get_wsa(hContact, MODULE, "Nick"));
+ for (auto &hContact : Contacts(MODULENAME)) {
+ ptrW dbNick(db_get_wsa(hContact, MODULENAME, "Nick"));
if (dbNick == NULL)
break;
if (mir_wstrcmp(dbNick, nick))
continue;
- ptrW dbURL(db_get_wsa(hContact, MODULE, "URL"));
+ ptrW dbURL(db_get_wsa(hContact, MODULENAME, "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 0cc91bec3e..4341b57672 100644 --- a/plugins/NewsAggregator/Src/Services.cpp +++ b/plugins/NewsAggregator/Src/Services.cpp @@ -36,10 +36,10 @@ int NewsAggrInit(WPARAM, LPARAM) else
mir_wstrncpy(tszRoot, VARSW(L"%miranda_userdata%\\Avatars\\" _A2W(DEFAULT_AVATARS_FOLDER)), _countof(tszRoot));
- for (auto &hContact : Contacts(MODULE)) {
- if (!db_get_b(NULL, MODULE, "StartupRetrieve", 1))
- db_set_dw(hContact, MODULE, "LastCheck", time(0));
- db_set_w(hContact, MODULE, "Status", ID_STATUS_ONLINE);
+ for (auto &hContact : Contacts(MODULENAME)) {
+ if (!db_get_b(NULL, MODULENAME, "StartupRetrieve", 1))
+ db_set_dw(hContact, MODULENAME, "LastCheck", time(0));
+ db_set_w(hContact, MODULENAME, "Status", ID_STATUS_ONLINE);
}
NetlibInit();
@@ -64,7 +64,7 @@ int NewsAggrPreShutdown(WPARAM, LPARAM) INT_PTR NewsAggrGetName(WPARAM wParam, LPARAM lParam)
{
if(lParam) {
- mir_strncpy((char *)lParam, MODULE, wParam);
+ mir_strncpy((char *)lParam, MODULENAME, wParam);
return 0;
}
@@ -96,10 +96,10 @@ INT_PTR NewsAggrSetStatus(WPARAM wp, LPARAM) if(nStatus != g_nStatus) {
g_nStatus = nStatus;
- for (auto &hContact : Contacts(MODULE))
- db_set_w(hContact, MODULE, "Status", nStatus);
+ for (auto &hContact : Contacts(MODULENAME))
+ db_set_w(hContact, MODULENAME, "Status", nStatus);
- ProtoBroadcastAck(MODULE, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)nOldStatus, g_nStatus);
+ ProtoBroadcastAck(MODULENAME, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)nOldStatus, g_nStatus);
}
}
@@ -119,7 +119,7 @@ INT_PTR NewsAggrLoadIcon(WPARAM wParam, LPARAM) static void __cdecl AckThreadProc(void *param)
{
Sleep(100);
- ProtoBroadcastAck(MODULE, (UINT_PTR)param, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE)1, 0);
+ ProtoBroadcastAck(MODULENAME, (UINT_PTR)param, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE)1, 0);
}
INT_PTR NewsAggrGetInfo(WPARAM, LPARAM lParam)
@@ -131,8 +131,8 @@ INT_PTR NewsAggrGetInfo(WPARAM, LPARAM lParam) INT_PTR CheckAllFeeds(WPARAM, LPARAM lParam)
{
- for (auto &hContact : Contacts(MODULE)) {
- if (lParam && db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME))
+ for (auto &hContact : Contacts(MODULENAME)) {
+ if (lParam && db_get_dw(hContact, MODULENAME, "UpdateTime", DEFAULT_UPDATE_TIME))
UpdateListAdd(hContact);
else if (!lParam)
UpdateListAdd(hContact);
@@ -207,12 +207,12 @@ 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, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME))
+ if ((wParam & GAIF_FORCE) && db_get_dw(pai->hContact, MODULENAME, "UpdateTime", DEFAULT_UPDATE_TIME))
UpdateListAdd(pai->hContact);
- if (db_get_b(NULL, MODULE, "AutoUpdate", 1) != 0 && !ThreadRunning)
+ if (db_get_b(NULL, MODULENAME, "AutoUpdate", 1) != 0 && !ThreadRunning)
mir_forkthread(UpdateThreadProc, (void *)TRUE);
- wchar_t *ptszImageURL = db_get_wsa(pai->hContact, MODULE, "ImageURL");
+ wchar_t *ptszImageURL = db_get_wsa(pai->hContact, MODULENAME, "ImageURL");
if(ptszImageURL == nullptr)
return GAIR_NOAVATAR;
@@ -222,7 +222,7 @@ INT_PTR NewsAggrGetAvatarInfo(WPARAM wParam, LPARAM lParam) INT_PTR NewsAggrRecvMessage(WPARAM, LPARAM lParam)
{
- PROTOACCOUNT *pa = Proto_GetAccount(MODULE);
+ PROTOACCOUNT *pa = Proto_GetAccount(MODULENAME);
if (pa && pa->ppro) {
CCSDATA *ccs = (CCSDATA*)lParam;
pa->ppro->PROTO_INTERFACE::RecvMsg(ccs->hContact, (PROTORECVEVENT*)ccs->lParam);
@@ -239,14 +239,14 @@ void UpdateMenu(bool State) Menu_ModifyItem(hService2[0], LPGENW("Auto Update Disabled"), GetIconHandle("disabled"));
CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hTBButton, State ? TTBST_PUSHED : 0);
- db_set_b(NULL, MODULE, "AutoUpdate", !State);
+ db_set_b(NULL, MODULENAME, "AutoUpdate", !State);
}
// update the newsaggregator auto-update menu item when click on it
INT_PTR EnableDisable(WPARAM, LPARAM)
{
- UpdateMenu(db_get_b(NULL, MODULE, "AutoUpdate", 1) != 0);
- NewsAggrSetStatus(db_get_b(NULL, MODULE, "AutoUpdate", 1) ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE, 0);
+ UpdateMenu(db_get_b(NULL, MODULENAME, "AutoUpdate", 1) != 0);
+ NewsAggrSetStatus(db_get_b(NULL, MODULENAME, "AutoUpdate", 1) ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE, 0);
return 0;
}
@@ -259,7 +259,7 @@ int OnToolbarLoaded(WPARAM, LPARAM) ttb.pszTooltipDn = LPGEN("Auto Update Disabled");
ttb.hIconHandleUp = GetIconHandle("enabled");
ttb.hIconHandleDn = GetIconHandle("disabled");
- ttb.dwFlags = (db_get_b(NULL, MODULE, "AutoUpdate", 1) ? 0 : TTBBF_PUSHED) | TTBBF_ASPUSHBUTTON | TTBBF_VISIBLE;
+ ttb.dwFlags = (db_get_b(NULL, MODULENAME, "AutoUpdate", 1) ? 0 : TTBBF_PUSHED) | TTBBF_ASPUSHBUTTON | TTBBF_VISIBLE;
hTBButton = TopToolbar_AddButton(&ttb);
return 0;
}
diff --git a/plugins/NewsAggregator/Src/Update.cpp b/plugins/NewsAggregator/Src/Update.cpp index 45db5d3f7e..7809904ad9 100644 --- a/plugins/NewsAggregator/Src/Update.cpp +++ b/plugins/NewsAggregator/Src/Update.cpp @@ -30,10 +30,10 @@ void CALLBACK timerProc(HWND, UINT, UINT_PTR, DWORD) // only run if it is not current updating and the auto update option is enabled
if (!ThreadRunning && !Miranda_IsTerminated()) {
bool HaveUpdates = FALSE;
- for (auto &hContact : Contacts(MODULE)) {
- if (db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME)) {
- double diff = difftime(time(0), (time_t)db_get_dw(hContact, MODULE, "LastCheck", 0));
- if (db_get_b(NULL, MODULE, "AutoUpdate", 1) != 0 && diff >= db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME) * 60) {
+ 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 (db_get_b(NULL, MODULENAME, "AutoUpdate", 1) != 0 && diff >= db_get_dw(hContact, MODULENAME, "UpdateTime", DEFAULT_UPDATE_TIME) * 60) {
UpdateListAdd(hContact);
HaveUpdates = TRUE;
}
@@ -51,8 +51,8 @@ void CALLBACK timerProc2(HWND, UINT, UINT_PTR, DWORD) KillTimer(nullptr, timerId);
ThreadRunning = FALSE;
- if (db_get_b(NULL, MODULE, "AutoUpdate", 1) && !Miranda_IsTerminated()) {
- if (db_get_b(NULL, MODULE, "StartupRetrieve", 1))
+ if (db_get_b(NULL, MODULENAME, "AutoUpdate", 1) && !Miranda_IsTerminated()) {
+ if (db_get_b(NULL, MODULENAME, "StartupRetrieve", 1))
CheckAllFeeds(0, 1);
timerId = SetTimer(nullptr, 0, 30000, (TIMERPROC)timerProc);
}
diff --git a/plugins/NewsAggregator/Src/Utils.cpp b/plugins/NewsAggregator/Src/Utils.cpp index 56a5a99182..47d97495d0 100644 --- a/plugins/NewsAggregator/Src/Utils.cpp +++ b/plugins/NewsAggregator/Src/Utils.cpp @@ -26,7 +26,7 @@ bool UpdateListFlag = FALSE; bool IsMyContact(MCONTACT hContact)
{
const char *szProto = GetContactProto(hContact);
- return szProto != nullptr && mir_strcmp(MODULE, szProto) == 0;
+ return szProto != nullptr && mir_strcmp(MODULENAME, szProto) == 0;
}
void NetlibInit()
@@ -34,7 +34,7 @@ void NetlibInit() NETLIBUSER nlu = {};
nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS | NUF_UNICODE;
nlu.szDescriptiveName.w = TranslateT("NewsAggregator HTTP connection");
- nlu.szSettingsModule = MODULE;
+ nlu.szSettingsModule = MODULENAME;
hNetlibUser = Netlib_RegisterUser(&nlu);
}
@@ -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, MODULE, "UseAuth", 0) || (pEditDlg && pEditDlg->m_useauth.IsChecked()) /*IsDlgButtonChecked(hwndDlg, IDC_USEAUTH)*/) {
+ if (db_get_b(hContact, MODULENAME, "UseAuth", 0) || (pEditDlg && pEditDlg->m_useauth.IsChecked()) /*IsDlgButtonChecked(hwndDlg, IDC_USEAUTH)*/) {
nlhr.headersCount++;
nlhr.headers[4].szName = "Authorization";
@@ -429,8 +429,8 @@ LPCTSTR ClearText(CMStringW &result, const wchar_t *message) MCONTACT GetContactByNick(const wchar_t *nick)
{
- for (auto &hContact : Contacts(MODULE)) {
- ptrW contactNick(::db_get_wsa(hContact, MODULE, "Nick"));
+ for (auto &hContact : Contacts(MODULENAME)) {
+ ptrW contactNick(::db_get_wsa(hContact, MODULENAME, "Nick"));
if (!mir_wstrcmpi(contactNick, nick))
return hContact;
}
@@ -439,8 +439,8 @@ MCONTACT GetContactByNick(const wchar_t *nick) MCONTACT GetContactByURL(const wchar_t *url)
{
- for (auto &hContact : Contacts(MODULE)) {
- ptrW contactURL(::db_get_wsa(hContact, MODULE, "URL"));
+ for (auto &hContact : Contacts(MODULENAME)) {
+ ptrW contactURL(::db_get_wsa(hContact, MODULENAME, "URL"));
if (!mir_wstrcmpi(contactURL, url))
return hContact;
}
diff --git a/plugins/NewsAggregator/Src/stdafx.h b/plugins/NewsAggregator/Src/stdafx.h index 834e47b174..d2215249cd 100644 --- a/plugins/NewsAggregator/Src/stdafx.h +++ b/plugins/NewsAggregator/Src/stdafx.h @@ -54,7 +54,7 @@ Boston, MA 02111-1307, USA. #include "version.h"
#include "resource.h"
-#define MODULE "NewsAggregator"
+#define MODULENAME "NewsAggregator"
#define TAGSDEFAULT L"#<title>#\r\n#<link>#\r\n#<description>#"
#define DEFAULT_AVATARS_FOLDER "NewsAggregator"
#define DEFAULT_UPDATE_TIME 60
@@ -70,12 +70,7 @@ extern wchar_t tszRoot[MAX_PATH]; struct CMPlugin : public PLUGIN<CMPlugin>
{
- CMPlugin() :
- PLUGIN<CMPlugin>(MODULE)
- {
- RegisterProtocol(PROTOTYPE_VIRTUAL);
- SetUniqueId("URL");
- }
+ CMPlugin();
};
//============ STRUCT USED TO MAKE AN UPDATE LIST ============
|