diff options
author | George Hazan <ghazan@miranda.im> | 2018-03-09 12:57:48 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-03-09 12:57:48 +0300 |
commit | 3e3526a52e25abfec0598f305cbc6d8b0049567b (patch) | |
tree | d6c3946c4e6143383e4e602f8a969b0bde248740 /plugins/NewsAggregator | |
parent | bd989f8f08faf42e19e4e62b507e13cd4643a4ac (diff) |
fix for broken service
Diffstat (limited to 'plugins/NewsAggregator')
-rw-r--r-- | plugins/NewsAggregator/Src/NewsAggregator.cpp | 7 | ||||
-rw-r--r-- | plugins/NewsAggregator/Src/Options.cpp | 35 | ||||
-rw-r--r-- | plugins/NewsAggregator/Src/Options.h | 2 | ||||
-rw-r--r-- | plugins/NewsAggregator/Src/Services.cpp | 29 | ||||
-rw-r--r-- | plugins/NewsAggregator/Src/stdafx.h | 9 | ||||
-rw-r--r-- | plugins/NewsAggregator/Src/version.h | 2 |
6 files changed, 38 insertions, 46 deletions
diff --git a/plugins/NewsAggregator/Src/NewsAggregator.cpp b/plugins/NewsAggregator/Src/NewsAggregator.cpp index c96acd118c..e30d9b7f02 100644 --- a/plugins/NewsAggregator/Src/NewsAggregator.cpp +++ b/plugins/NewsAggregator/Src/NewsAggregator.cpp @@ -23,11 +23,12 @@ HINSTANCE hInst = nullptr; int hLangpack;
HANDLE hPrebuildMenuHook = nullptr;
-CDlgBase *pAddFeedDialog = nullptr, *pChangeFeedDialog = nullptr, *pImportDialog = nullptr, *pExportDialog = nullptr;
-//MWindowList hChangeFeedDlgList = nullptr;
+CDlgBase *pAddFeedDialog = nullptr, *pImportDialog = nullptr, *pExportDialog = nullptr;
wchar_t tszRoot[MAX_PATH] = {0};
HANDLE hUpdateMutex;
+LIST<CFeedEditor> g_arFeeds(1, PtrKeySortT);
+
PLUGININFOEX pluginInfoEx = {
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
@@ -62,7 +63,6 @@ extern "C" __declspec(dllexport) int Load(void) HookEvent(ME_SYSTEM_PRESHUTDOWN, NewsAggrPreShutdown);
hUpdateMutex = CreateMutex(nullptr, FALSE, nullptr);
- //hChangeFeedDlgList = WindowList_Create();
// register weather protocol
PROTOCOLDESCRIPTOR pd = { 0 };
@@ -104,7 +104,6 @@ extern "C" __declspec(dllexport) int Load(void) extern "C" __declspec(dllexport) int Unload(void)
{
- //WindowList_Destroy(hChangeFeedDlgList);
DestroyUpdateList();
CloseHandle(hUpdateMutex);
return 0;
diff --git a/plugins/NewsAggregator/Src/Options.cpp b/plugins/NewsAggregator/Src/Options.cpp index 8abf2657e8..01b2262edc 100644 --- a/plugins/NewsAggregator/Src/Options.cpp +++ b/plugins/NewsAggregator/Src/Options.cpp @@ -687,7 +687,7 @@ void CFeedEditor::OnInitDialog() m_checktime.SetMaxLength(3);
m_checktimespin.SetRange(999, 0);
- if (m_iItem > -1 && m_hContact == NULL) {
+ if (m_iItem > -1 && m_hContact == 0) {
wchar_t SelNick[MAX_PATH], SelUrl[MAX_PACKAGE_NAME];
m_list->GetItemText(m_iItem, 0, SelNick, _countof(SelNick));
m_list->GetItemText(m_iItem, 1, SelUrl, _countof(SelNick));
@@ -724,7 +724,7 @@ void CFeedEditor::OnInitDialog() pass_ptrA pwd(db_get_sa(hContact, MODULE, "Password"));
m_password.SetTextA(pwd);
}
- //WindowList_Add(hChangeFeedDlgList, m_hwnd, hContact);
+ g_arFeeds.insert(this);
Utils_RestoreWindowPositionNoSize(m_hwnd, hContact, MODULE, "ChangeDlg");
break;
}
@@ -761,7 +761,7 @@ void CFeedEditor::OnInitDialog() pass_ptrA pwd(db_get_sa(m_hContact, MODULE, "Password"));
m_password.SetTextA(pwd);
}
- //WindowList_Add(hChangeFeedDlgList, m_hwnd, m_hContact);
+ g_arFeeds.insert(this);
Utils_RestoreWindowPositionNoSize(m_hwnd, m_hContact, MODULE, "ChangeDlg");
}
}
@@ -860,10 +860,9 @@ void CFeedEditor::OnOk(CCtrlBase*) void CFeedEditor::OnClose()
{
+ g_arFeeds.remove(this);
Utils_SaveWindowPosition(m_hwnd, NULL, MODULE, m_iItem == -1 ? "AddDlg" : "ChangeDlg");
- if (pChangeFeedDialog)
- pChangeFeedDialog = nullptr;
- if (pAddFeedDialog)
+ if (pAddFeedDialog == this)
pAddFeedDialog = nullptr;
}
@@ -950,19 +949,17 @@ void COptionsMain::OnAddButtonClick(CCtrlBase*) {
if (pAddFeedDialog == nullptr) {
pAddFeedDialog = new CFeedEditor(-1, &m_feeds, NULL);
- pAddFeedDialog->Show();
pAddFeedDialog->SetParent(m_hwnd);
+ pAddFeedDialog->Show();
}
}
void COptionsMain::OnChangeButtonClick(CCtrlBase*)
{
- if (pChangeFeedDialog == nullptr) {
- int isel = m_feeds.GetSelectionMark();
- pChangeFeedDialog = new CFeedEditor(isel, &m_feeds, NULL);
- pChangeFeedDialog->Show();
- pChangeFeedDialog->SetParent(m_hwnd);
- }
+ int isel = m_feeds.GetSelectionMark();
+ CFeedEditor *pDlg = new CFeedEditor(isel, &m_feeds, NULL);
+ pDlg->SetParent(m_hwnd);
+ pDlg->Show();
}
void COptionsMain::OnDeleteButtonClick(CCtrlBase*)
@@ -1028,13 +1025,11 @@ void COptionsMain::OnFeedListItemChanged(CCtrlListView::TEventInfo *evt) void COptionsMain::OnFeedListDoubleClick(CCtrlBase*)
{
- if (pChangeFeedDialog == nullptr) {
- int isel = m_feeds.GetHotItem();
- if (isel != -1) {
- pChangeFeedDialog = new CFeedEditor(isel, &m_feeds, NULL);
- pChangeFeedDialog->Show();
- pChangeFeedDialog->SetParent(m_hwnd);
- }
+ int isel = m_feeds.GetHotItem();
+ if (isel != -1) {
+ CFeedEditor *pDlg = new CFeedEditor(isel, &m_feeds, 0);
+ pDlg->SetParent(m_hwnd);
+ pDlg->Show();
}
}
diff --git a/plugins/NewsAggregator/Src/Options.h b/plugins/NewsAggregator/Src/Options.h index 41d2274db5..51bafad7b3 100644 --- a/plugins/NewsAggregator/Src/Options.h +++ b/plugins/NewsAggregator/Src/Options.h @@ -64,6 +64,8 @@ protected: public: CFeedEditor(int iItem, CCtrlListView *m_list, MCONTACT Contact); + + __inline MCONTACT getContact() const { return m_hContact; } }; class CImportFeed : public CDlgBase diff --git a/plugins/NewsAggregator/Src/Services.cpp b/plugins/NewsAggregator/Src/Services.cpp index ad96232894..07a40ef28f 100644 --- a/plugins/NewsAggregator/Src/Services.cpp +++ b/plugins/NewsAggregator/Src/Services.cpp @@ -157,20 +157,19 @@ INT_PTR AddFeed(WPARAM, LPARAM) INT_PTR ChangeFeed(WPARAM hContact, LPARAM)
{
- //HWND hChangeFeedDlg = WindowList_Find(hChangeFeedDlgList, hContact);
-
- if (pChangeFeedDialog == nullptr) {
- pChangeFeedDialog = new CFeedEditor(-1, nullptr, hContact);
- pChangeFeedDialog->Show();
+ CFeedEditor *pDlg = nullptr;
+ for (auto &it : g_arFeeds)
+ if (it->getContact() == hContact)
+ pDlg = it;
+
+ if (pDlg == nullptr) {
+ pDlg = new CFeedEditor(-1, nullptr, hContact);
+ pDlg->Show();
+ }
+ else {
+ SetForegroundWindow(pDlg->GetHwnd());
+ SetFocus(pDlg->GetHwnd());
}
-
- /*if (!hChangeFeedDlg) {
- hChangeFeedDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADDFEED), nullptr, DlgProcChangeFeedMenu, hContact);
- ShowWindow(hChangeFeedDlg, SW_SHOW);
- } else {
- SetForegroundWindow(hChangeFeedDlg);
- SetFocus(hChangeFeedDlg);
- }*/
return 0;
}
@@ -179,8 +178,6 @@ INT_PTR ImportFeeds(WPARAM, LPARAM) if (pImportDialog == nullptr)
pImportDialog = new CImportFeed(nullptr);
pImportDialog->Show();
-
- //CreateDialog(hInst, MAKEINTRESOURCE(IDD_FEEDIMPORT), nullptr, DlgProcImportOpts);
return 0;
}
@@ -189,8 +186,6 @@ INT_PTR ExportFeeds(WPARAM, LPARAM) if (pExportDialog == nullptr)
pExportDialog = new CExportFeed();
pExportDialog->Show();
-
- //CreateDialog(hInst, MAKEINTRESOURCE(IDD_FEEDEXPORT), nullptr, DlgProcExportOpts);
return 0;
}
diff --git a/plugins/NewsAggregator/Src/stdafx.h b/plugins/NewsAggregator/Src/stdafx.h index bbce47d74d..cc1978b908 100644 --- a/plugins/NewsAggregator/Src/stdafx.h +++ b/plugins/NewsAggregator/Src/stdafx.h @@ -60,14 +60,15 @@ Boston, MA 02111-1307, USA. #define DEFAULT_UPDATE_TIME 60
extern HINSTANCE hInst;
-extern CDlgBase *pAddFeedDialog, *pChangeFeedDialog, *pImportDialog, *pExportDialog;
-//extern MWindowList hChangeFeedDlgList;
+extern CDlgBase *pAddFeedDialog, *pImportDialog, *pExportDialog;
extern HNETLIBUSER hNetlibUser;
extern UINT_PTR timerId;
+extern LIST<CFeedEditor> g_arFeeds;
// check if Feeds is currently updating
extern bool ThreadRunning;
extern bool UpdateListFlag;
extern wchar_t tszRoot[MAX_PATH];
+
struct ItemInfo
{
HWND hwndList;
@@ -90,7 +91,7 @@ extern UPDATELIST *UpdateListHead; extern UPDATELIST *UpdateListTail;
void UpdateListAdd(MCONTACT hContact);
-void UpdateThreadProc(LPVOID AvatarCheck);
+void UpdateThreadProc(void*);
void DestroyUpdateList(void);
extern HANDLE hUpdateMutex;
@@ -167,4 +168,4 @@ MCONTACT GetContactByURL(const wchar_t *url); // Enable/disable getting feed info
// WPARAM = LPARAM = NULL
-#define MS_NEWSAGGREGATOR_ENABLED "NewsAggregator/Enabled"
\ No newline at end of file +#define MS_NEWSAGGREGATOR_ENABLED "NewsAggregator/Enabled"
diff --git a/plugins/NewsAggregator/Src/version.h b/plugins/NewsAggregator/Src/version.h index 3d2eb2d0a3..0654d0be1d 100644 --- a/plugins/NewsAggregator/Src/version.h +++ b/plugins/NewsAggregator/Src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 1 #define __RELEASE_NUM 0 -#define __BUILD_NUM 3 +#define __BUILD_NUM 4 #include <stdver.h> |