From ae93aa98b214f98a0e28df1bdaa8df18b3f6da02 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 2 Mar 2017 14:12:59 +0300 Subject: further SRMM window unification - CSrmmBaseDialog received m_hContact as its common member; - less usage of CTabBaseDlg::m_bType in tabSRMM --- plugins/Scriver/src/chat/window.cpp | 45 +++++++++++++++++++------------------ plugins/Scriver/src/msgdialog.cpp | 16 ++++++------- plugins/Scriver/src/msgs.h | 19 ++++++++-------- plugins/Scriver/src/utils.cpp | 4 ++-- plugins/Scriver/src/utils.h | 1 - 5 files changed, 43 insertions(+), 42 deletions(-) (limited to 'plugins/Scriver/src') diff --git a/plugins/Scriver/src/chat/window.cpp b/plugins/Scriver/src/chat/window.cpp index 982cbd02cf..3655e3c4b7 100644 --- a/plugins/Scriver/src/chat/window.cpp +++ b/plugins/Scriver/src/chat/window.cpp @@ -895,7 +895,7 @@ class CChatRoomDlg : public CSrmmBaseDialog hdwp = DeferWindowPos(hdwp, GetDlgItem(m_hwnd, IDC_MESSAGE), 0, 1, h - m_si->iSplitterY + SPLITTER_HEIGHT, w - 2, m_si->iSplitterY - SPLITTER_HEIGHT - 1, SWP_NOZORDER); EndDeferWindowPos(hdwp); - SetButtonsPos(m_hwnd, m_si->hContact, bToolbar); + SetButtonsPos(m_hwnd, m_hContact, bToolbar); if (m_si->m_hwndIeview != NULL) { IEVIEWWINDOW ieWindow; @@ -926,11 +926,12 @@ public: m_pLog = &m_log; m_pEntry = &m_message; m_autoClose = 0; + m_hContact = si->hContact; } virtual void OnInitDialog() override { - NotifyLocalWinEvent(m_si->hContact, m_hwnd, MSG_WINDOW_EVT_OPENING); + NotifyLocalWinEvent(m_hContact, m_hwnd, MSG_WINDOW_EVT_OPENING); SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LONG_PTR)m_si); @@ -975,7 +976,7 @@ public: IEVIEWEVENT iee = { sizeof(iee) }; iee.iType = IEE_CLEAR_LOG; iee.hwnd = m_si->m_hwndIeview; - iee.hContact = m_si->hContact; + iee.hContact = m_hContact; iee.pszProto = m_si->pszModule; CallService(MS_IEVIEW_EVENT, 0, (LPARAM)&iee); } @@ -986,14 +987,14 @@ public: SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0); SendMessage(m_hwnd, DM_UPDATETITLEBAR, 0, 0); - SendMessage(m_hwndParent, CM_ADDCHILD, (WPARAM)m_hwnd, m_si->hContact); + SendMessage(m_hwndParent, CM_ADDCHILD, (WPARAM)m_hwnd, m_hContact); PostMessage(m_hwnd, GC_UPDATENICKLIST, 0, 0); - NotifyLocalWinEvent(m_si->hContact, m_hwnd, MSG_WINDOW_EVT_OPEN); + NotifyLocalWinEvent(m_hContact, m_hwnd, MSG_WINDOW_EVT_OPEN); } virtual void OnDestroy() override { - NotifyLocalWinEvent(m_si->hContact, m_hwnd, MSG_WINDOW_EVT_CLOSING); + NotifyLocalWinEvent(m_hContact, m_hwnd, MSG_WINDOW_EVT_CLOSING); m_si->hWnd = NULL; SetWindowLongPtr(m_hwnd, GWLP_USERDATA, 0); @@ -1007,7 +1008,7 @@ public: CallService(MS_IEVIEW_WINDOW, 0, (LPARAM)&ieWindow); } - NotifyLocalWinEvent(m_si->hContact, m_hwnd, MSG_WINDOW_EVT_CLOSE); + NotifyLocalWinEvent(m_hContact, m_hwnd, MSG_WINDOW_EVT_CLOSE); } virtual INT_PTR DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) override @@ -1115,7 +1116,7 @@ public: StatusIconData sid = { sizeof(sid) }; sid.szModule = SRMMMOD; - Srmm_ModifyIcon(m_si->hContact, &sid); + Srmm_ModifyIcon(m_hContact, &sid); } break; @@ -1213,14 +1214,14 @@ public: case DM_ACTIVATE: if (m_si->wState & STATE_TALK) { m_si->wState &= ~STATE_TALK; - db_set_w(m_si->hContact, m_si->pszModule, "ApparentMode", 0); + db_set_w(m_hContact, m_si->pszModule, "ApparentMode", 0); } if (m_si->wState & GC_EVENT_HIGHLIGHT) { m_si->wState &= ~GC_EVENT_HIGHLIGHT; - if (pcli->pfnGetEvent(m_si->hContact, 0)) - pcli->pfnRemoveEvent(m_si->hContact, GC_FAKE_EVENT); + if (pcli->pfnGetEvent(m_hContact, 0)) + pcli->pfnRemoveEvent(m_hContact, GC_FAKE_EVENT); } SendMessage(m_hwnd, GC_FIXTABICONS, 0, 0); @@ -1342,10 +1343,10 @@ public: return TRUE; case SESSION_TERMINATE: - if (pcli->pfnGetEvent(m_si->hContact, 0)) - pcli->pfnRemoveEvent(m_si->hContact, GC_FAKE_EVENT); + if (pcli->pfnGetEvent(m_hContact, 0)) + pcli->pfnRemoveEvent(m_hContact, GC_FAKE_EVENT); m_si->wState &= ~STATE_TALK; - db_set_w(m_si->hContact, m_si->pszModule, "ApparentMode", 0); + db_set_w(m_hContact, m_si->pszModule, "ApparentMode", 0); SendMessage(m_hwnd, GC_CLOSEWINDOW, 0, 0); return TRUE; @@ -1461,10 +1462,10 @@ public: pci->SetActiveSession(m_si->ptszID, m_si->pszModule); - if (db_get_w(m_si->hContact, m_si->pszModule, "ApparentMode", 0) != 0) - db_set_w(m_si->hContact, m_si->pszModule, "ApparentMode", 0); - if (pcli->pfnGetEvent(m_si->hContact, 0)) - pcli->pfnRemoveEvent(m_si->hContact, GC_FAKE_EVENT); + if (db_get_w(m_hContact, m_si->pszModule, "ApparentMode", 0) != 0) + db_set_w(m_hContact, m_si->pszModule, "ApparentMode", 0); + if (pcli->pfnGetEvent(m_hContact, 0)) + pcli->pfnRemoveEvent(m_hContact, GC_FAKE_EVENT); break; case WM_NOTIFY: @@ -1518,12 +1519,12 @@ public: break; case WM_COMMAND: - if (!lParam && Clist_MenuProcessCommand(LOWORD(wParam), MPCF_CONTACTMENU, m_si->hContact)) + if (!lParam && Clist_MenuProcessCommand(LOWORD(wParam), MPCF_CONTACTMENU, m_hContact)) break; if (HIWORD(wParam) == BN_CLICKED) if (LOWORD(wParam) >= MIN_CBUTTONID && LOWORD(wParam) <= MAX_CBUTTONID) { - Srmm_ClickToolbarIcon(m_si->hContact, LOWORD(wParam), GetDlgItem(m_hwnd, LOWORD(wParam)), 0); + Srmm_ClickToolbarIcon(m_hContact, LOWORD(wParam), GetDlgItem(m_hwnd, LOWORD(wParam)), 0); break; } @@ -1771,12 +1772,12 @@ public: return TRUE; case DM_GETCONTEXTMENU: - SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, (LPARAM)Menu_BuildContactMenu(m_si->hContact)); + SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, (LPARAM)Menu_BuildContactMenu(m_hContact)); return TRUE; case WM_CONTEXTMENU: if (m_hwndParent == (HWND)wParam) { - HMENU hMenu = Menu_BuildContactMenu(m_si->hContact); + HMENU hMenu = Menu_BuildContactMenu(m_hContact); GetCursorPos(&pt); TrackPopupMenu(hMenu, 0, pt.x, pt.y, 0, m_hwnd, NULL); DestroyMenu(hMenu); diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 0d6440c9eb..0b8fb28a86 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -30,11 +30,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern HCURSOR hCurSplitNS, hCurSplitWE, hCurHyperlinkHand, hDragCursor; extern HANDLE hHookWinEvt; -static wchar_t* GetIEViewSelection(CSrmmWindow *dat) +wchar_t* CSrmmWindow::GetIEViewSelection() { IEVIEWEVENT evt = { sizeof(evt) }; - evt.hwnd = dat->m_hwndIeview; - evt.hContact = dat->m_hContact; + evt.hwnd = m_hwndIeview; + evt.hContact = m_hContact; evt.iType = IEE_GET_SELECTION; return mir_wstrdup((wchar_t*)CallService(MS_IEVIEW_EVENT, 0, (LPARAM)&evt)); } @@ -636,11 +636,11 @@ CSrmmWindow::CSrmmWindow(MCONTACT hContact, bool bIncoming, const char *szInitia : CSrmmBaseDialog(g_hInst, IDD_MSG), m_log(this, IDC_LOG), m_message(this, IDC_MESSAGE), - m_bIncoming(bIncoming), - m_hContact(hContact) + m_bIncoming(bIncoming) { m_pLog = &m_log; m_pEntry = &m_message; + m_hContact = hContact; m_hwndParent = GetParentWindow(hContact, FALSE); m_wszInitialText = (bIsUnicode) ? mir_wstrdup((wchar_t*)szInitialText) : mir_a2u(szInitialText); @@ -998,7 +998,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) if (m_hContact && m_szProto) { DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)lParam; char idbuf[128], buf[128]; - GetContactUniqueId(this, idbuf, sizeof(idbuf)); + GetContactUniqueId(idbuf, sizeof(idbuf)); mir_snprintf(buf, Translate("User menu - %s"), idbuf); SendDlgItemMessage(m_hwnd, IDC_USERMENU, BUTTONADDTOOLTIP, (WPARAM)buf, 0); @@ -1083,7 +1083,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) case DM_USERNAMETOCLIP: if (m_hContact) { char buf[128]; - GetContactUniqueId(this, buf, sizeof(buf)); + GetContactUniqueId(buf, sizeof(buf)); if (!OpenClipboard(m_hwnd) || !mir_strlen(buf)) break; @@ -1626,7 +1626,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) wchar_t *buffer = NULL; if (m_hwndIeview != NULL) - buffer = GetIEViewSelection(this); + buffer = GetIEViewSelection(); else buffer = GetRichEditSelection(GetDlgItem(m_hwnd, IDC_LOG)); diff --git a/plugins/Scriver/src/msgs.h b/plugins/Scriver/src/msgs.h index a2873ce784..3374631830 100644 --- a/plugins/Scriver/src/msgs.h +++ b/plugins/Scriver/src/msgs.h @@ -122,21 +122,22 @@ class CSrmmWindow : public CSrmmBaseDialog, public MZeroedObject, public CommonW InfobarWindowData *m_pInfobarData; - HICON GetTabIcon(); - void GetTitlebarIcon(struct TitleBarData *tbd); - void MessageDialogResize(int w, int h); - void ShowAvatar(); - void SetDialogToType(); - void SetStatusIcon(); - void StreamInEvents(MEVENT hDbEventFirst, int count, int fAppend); - void UpdateReadChars(); + void GetContactUniqueId(char *buf, int maxlen); + wchar_t* GetIEViewSelection(); + HICON GetTabIcon(); + void GetTitlebarIcon(struct TitleBarData *tbd); + void MessageDialogResize(int w, int h); + void ShowAvatar(); + void SetDialogToType(); + void SetStatusIcon(); + void StreamInEvents(MEVENT hDbEventFirst, int count, int fAppend); + void UpdateReadChars(); bool IsTypingNotificationEnabled(); bool IsTypingNotificationSupported(); void NotifyTyping(int mode); public: - MCONTACT m_hContact; char *m_szProto; time_t m_startTime, m_lastEventTime; int m_lastEventType; diff --git a/plugins/Scriver/src/utils.cpp b/plugins/Scriver/src/utils.cpp index a615d5dd5b..c68c1518f6 100644 --- a/plugins/Scriver/src/utils.cpp +++ b/plugins/Scriver/src/utils.cpp @@ -385,9 +385,9 @@ void SetSearchEngineIcons(HMENU hMenu, HIMAGELIST hImageList) } } -void GetContactUniqueId(CSrmmWindow *dat, char *buf, int maxlen) +void CSrmmWindow::GetContactUniqueId(char *buf, int maxlen) { - ptrW id(Contact_GetInfo(CNF_UNIQUEID, dat->m_hContact, dat->m_szProto)); + ptrW id(Contact_GetInfo(CNF_UNIQUEID, m_hContact, m_szProto)); if (id != NULL) strncpy_s(buf, maxlen, _T2A(id), _TRUNCATE); } diff --git a/plugins/Scriver/src/utils.h b/plugins/Scriver/src/utils.h index 051de4800d..bf01163431 100644 --- a/plugins/Scriver/src/utils.h +++ b/plugins/Scriver/src/utils.h @@ -48,7 +48,6 @@ void AppendToBuffer(char *&buffer, size_t &cbBufferEnd, size_t &cbBufferAlloced, int MeasureMenuItem(WPARAM wParam, LPARAM lParam); int DrawMenuItem(WPARAM wParam, LPARAM lParam); void SetSearchEngineIcons(HMENU hMenu, HIMAGELIST hImageList); -void GetContactUniqueId(class CSrmmWindow *dat, char *buf, int maxlen); HWND CreateToolTip(HWND hwndParent, LPTSTR ptszText, LPTSTR ptszTitle, RECT *rect); void SetToolTipText(HWND hwndParent, HWND hwndTT, LPTSTR ptszText, LPTSTR ptszTitle); void SetToolTipRect(HWND hwndParent, HWND hwndTT, RECT* rect); -- cgit v1.2.3