summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-03-09 23:27:40 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-03-09 23:27:40 +0300
commit063a61cf745e1c51f4c9791d03832740f7dc0347 (patch)
tree960bae1ec8b3869c561cf95e9717c01dd08c735b /src/mir_app
parentf3ff9ad5341bb0b0a0453e61a2d419e8c02f14b0 (diff)
- GCSessionInfoBase fields iWidth and iHeight moved to StdMSg;
- CHAT_MANAGER methods DoEventHook & DoEventHookAsync removed from CHAT_API; - CSrmmBaseDialog::DoEventHook introduced instead
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/src/chat.h1
-rw-r--r--src/mir_app/src/chat_manager.cpp31
-rw-r--r--src/mir_app/src/chat_tools.cpp41
-rw-r--r--src/mir_app/src/mir_app.def1
-rw-r--r--src/mir_app/src/mir_app64.def1
-rw-r--r--src/mir_app/src/srmm_base.cpp127
6 files changed, 96 insertions, 106 deletions
diff --git a/src/mir_app/src/chat.h b/src/mir_app/src/chat.h
index fbfc8872f6..d081407ac6 100644
--- a/src/mir_app/src/chat.h
+++ b/src/mir_app/src/chat.h
@@ -109,7 +109,6 @@ int GetRichTextLength(HWND hwnd);
bool IsHighlighted(SESSION_INFO *si, GCEVENT *pszText);
UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, wchar_t* pszUID, wchar_t* pszWordText);
void DestroyGCMenu(HMENU *hMenu, int iIndex);
-BOOL DoEventHookAsync(HWND hwnd, const wchar_t *pszID, const char *pszModule, int iType, const USERINFO *pUser, const wchar_t* pszText, INT_PTR dwItem);
BOOL DoEventHook(SESSION_INFO *si, int iType, const USERINFO *pUser, const wchar_t* pszText, INT_PTR dwItem);
BOOL IsEventSupported(int eventType);
BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce);
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp
index bdd3604861..59e7bb27cc 100644
--- a/src/mir_app/src/chat_manager.cpp
+++ b/src/mir_app/src/chat_manager.cpp
@@ -187,12 +187,12 @@ static HICON SM_GetStatusIcon(SESSION_INFO *si, USERINFO * ui)
BOOL SM_AddEvent(const wchar_t *pszID, const char *pszModule, GCEVENT *gce, bool bIsHighlighted)
{
- SESSION_INFO *p = SM_FindSession(pszID, pszModule);
- if (p == nullptr)
+ SESSION_INFO *si = SM_FindSession(pszID, pszModule);
+ if (si == nullptr)
return TRUE;
- LOGINFO *li = chatApi.LM_AddEvent(&p->pLog, &p->pLogEnd);
- p->iEventCount += 1;
+ LOGINFO *li = chatApi.LM_AddEvent(&si->pLog, &si->pLogEnd);
+ si->iEventCount++;
li->iType = gce->pDest->iType;
li->ptszNick = mir_wstrdup(gce->ptszNick);
@@ -204,10 +204,10 @@ BOOL SM_AddEvent(const wchar_t *pszID, const char *pszModule, GCEVENT *gce, bool
li->time = gce->time;
li->bIsHighlighted = bIsHighlighted;
- if (g_Settings->iEventLimit > 0 && p->iEventCount > g_Settings->iEventLimit + 20) {
- chatApi.LM_TrimLog(&p->pLog, &p->pLogEnd, p->iEventCount - g_Settings->iEventLimit);
- p->bTrimmed = true;
- p->iEventCount = g_Settings->iEventLimit;
+ if (g_Settings->iEventLimit > 0 && si->iEventCount > g_Settings->iEventLimit + 20) {
+ chatApi.LM_TrimLog(&si->pLog, &si->pLogEnd, si->iEventCount - g_Settings->iEventLimit);
+ si->bTrimmed = true;
+ si->iEventCount = g_Settings->iEventLimit;
return FALSE;
}
return TRUE;
@@ -437,7 +437,9 @@ static void SM_AddCommand(const wchar_t *pszID, const char *pszModule, const cha
if (si->wCommandsNum > WINDOWS_COMMANDS_MAX) {
COMMANDINFO *pCurComm = si->lpCommands;
- while (pCurComm->next != nullptr) { pCurComm = pCurComm->next; }
+ while (pCurComm->next != nullptr)
+ pCurComm = pCurComm->next;
+
COMMANDINFO *pLast = pCurComm->last;
mir_free(pCurComm->lpCommand);
mir_free(pCurComm);
@@ -527,7 +529,7 @@ char* SM_GetUsers(SESSION_INFO *si)
if (utemp == nullptr)
return nullptr;
- char* p = nullptr;
+ char *p = nullptr;
size_t alloced = 0;
do {
size_t pLen = mir_strlen(p), nameLen = mir_wstrlen(utemp->pszUID);
@@ -1041,12 +1043,6 @@ static BOOL LM_RemoveAll(LOGINFO **ppLogListStart, LOGINFO **ppLogListEnd)
return TRUE;
}
-static BOOL DoEventHook(const wchar_t *pszID, const char *pszModule, int iType, const USERINFO *pUser, const wchar_t* pszText, INT_PTR dwItem)
-{
- SESSION_INFO *si = chatApi.SM_FindSession(pszID, pszModule);
- return (si) ? DoEventHook(si, iType, pUser, pszText, dwItem) : FALSE;
-}
-
MIR_APP_DLL(CHAT_MANAGER*) Chat_GetInterface(CHAT_MANAGER_INITDATA *pInit, int _hLangpack)
{
if (pInit == nullptr)
@@ -1146,9 +1142,6 @@ MIR_APP_DLL(CHAT_MANAGER*) Chat_GetInterface(CHAT_MANAGER_INITDATA *pInit, int _
chatApi.LoadMsgDlgFont = LoadMsgDlgFont;
chatApi.MakeTimeStamp = MakeTimeStamp;
- chatApi.DoEventHook = DoEventHook;
- chatApi.DoEventHookAsync = DoEventHookAsync;
-
chatApi.DoSoundsFlashPopupTrayStuff = DoSoundsFlashPopupTrayStuff;
chatApi.DoTrayIcon = DoTrayIcon;
chatApi.DoPopup = DoPopup;
diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp
index 13f573a2c4..0257297ead 100644
--- a/src/mir_app/src/chat_tools.cpp
+++ b/src/mir_app/src/chat_tools.cpp
@@ -606,31 +606,6 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce)
return TRUE;
}
-BOOL DoEventHookAsync(HWND hwnd, const wchar_t *pszID, const char *pszModule, int iType, const USERINFO *pUser, const wchar_t* pszText, INT_PTR dwItem)
-{
- SESSION_INFO *si = chatApi.SM_FindSession(pszID, pszModule);
- if (si == NULL)
- return FALSE;
-
- GCDEST *gcd = (GCDEST*)mir_calloc(sizeof(GCDEST));
- gcd->pszModule = mir_strdup(pszModule);
- gcd->ptszID = mir_wstrdup(pszID);
- gcd->iType = iType;
-
- GCHOOK *gch = (GCHOOK*)mir_calloc(sizeof(GCHOOK));
- if (pUser != NULL) {
- gch->ptszUID = mir_wstrdup(pUser->pszUID);
- gch->ptszNick = mir_wstrdup(pUser->pszNick);
- }
- else gch->ptszUID = gch->ptszNick = nullptr;
-
- gch->ptszText = mir_wstrdup(pszText);
- gch->dwData = dwItem;
- gch->pDest = gcd;
- PostMessage(hwnd, GC_FIREHOOK, 0, (LPARAM)gch);
- return TRUE;
-}
-
BOOL DoEventHook(SESSION_INFO *si, int iType, const USERINFO *pUser, const wchar_t* pszText, INT_PTR dwItem)
{
if (si == nullptr)
@@ -851,22 +826,22 @@ static void CALLBACK ChatTimerProc(HWND hwnd, UINT, UINT_PTR idEvent, DWORD)
USERINFO *ui1 = chatApi.SM_GetUserFromIndex(si->ptszID, si->pszModule, si->currentHovered);
if (ui1) {
- wchar_t tszBuf[1024]; tszBuf[0] = 0;
+ CMStringW wszBuf;
if (ProtoServiceExists(si->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT)) {
wchar_t *p = (wchar_t*)CallProtoService(si->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT, (WPARAM)si->ptszID, (LPARAM)ui1->pszUID);
if (p) {
- wcsncpy_s(tszBuf, p, _TRUNCATE);
+ wszBuf = p;
mir_free(p);
}
}
- if (tszBuf[0] == 0)
- mir_snwprintf(tszBuf, L"<b>%s:</b>\t%s\n<b>%s:</b>\t%s\n<b>%s:</b>\t%s",
- TranslateT("Nick"), ui1->pszNick,
- TranslateT("Unique ID"), ui1->pszUID,
- TranslateT("Status"), chatApi.TM_WordToString(si->pStatuses, ui1->Status));
+ if (wszBuf.IsEmpty())
+ wszBuf.Format(L"<b>%s:</b>\t%s\n<b>%s:</b>\t%s\n<b>%s:</b>\t%s",
+ TranslateT("Nick"), ui1->pszNick,
+ TranslateT("Unique ID"), ui1->pszUID,
+ TranslateT("Status"), chatApi.TM_WordToString(si->pStatuses, ui1->Status));
CLCINFOTIP ti = { sizeof(ti) };
- if (CallService("mToolTip/ShowTipW", (WPARAM)tszBuf, (LPARAM)&ti))
+ if (CallService("mToolTip/ShowTipW", (WPARAM)wszBuf.c_str(), (LPARAM)&ti))
si->bHasToolTip = true;
}
KillTimer(hwnd, idEvent);
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index d6414d4a10..c2562b7c58 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -410,3 +410,4 @@ ProtoGetAvatarMimeType @401
?isChat@CSrmmBaseDialog@@QBE_NXZ @411 NONAME
Srmm_LogStreamCallback @412
Srmm_MessageStreamCallback @413
+?DoEventHook@CSrmmBaseDialog@@IAEXHPBUUSERINFO@@PB_WH@Z @414 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 1c66d0534a..8c86e46402 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -410,3 +410,4 @@ ProtoGetAvatarMimeType @401
?isChat@CSrmmBaseDialog@@QEBA_NXZ @411 NONAME
Srmm_LogStreamCallback @412
Srmm_MessageStreamCallback @413
+?DoEventHook@CSrmmBaseDialog@@IEAAXHPEBUUSERINFO@@PEB_W_J@Z @414 NONAME
diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp
index 0d007ea68f..cb7e7430de 100644
--- a/src/mir_app/src/srmm_base.cpp
+++ b/src/mir_app/src/srmm_base.cpp
@@ -27,8 +27,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern HCURSOR g_hCurHyperlinkHand;
-CSrmmBaseDialog::CSrmmBaseDialog(HINSTANCE hInst, int idDialog, SESSION_INFO *si) :
- CDlgBase(hInst, idDialog),
+CSrmmBaseDialog::CSrmmBaseDialog(HINSTANCE hInst, int idDialog, SESSION_INFO *si)
+ : CDlgBase(hInst, idDialog),
m_si(si),
m_pLog(nullptr),
m_pEntry(nullptr),
@@ -57,71 +57,92 @@ CSrmmBaseDialog::CSrmmBaseDialog(HINSTANCE hInst, int idDialog, SESSION_INFO *si
INT_PTR CSrmmBaseDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
- CHARRANGE sel;
-
- if (msg == WM_NOTIFY && m_pLog != nullptr) {
- LPNMHDR hdr = (LPNMHDR)lParam;
- if (hdr->hwndFrom == m_pLog->GetHwnd() && hdr->code == EN_LINK) {
- ENLINK *pLink = (ENLINK*)lParam;
- switch (pLink->msg) {
- case WM_SETCURSOR:
- SetCursor(g_hCurHyperlinkHand);
- SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, TRUE);
- return TRUE;
-
- case WM_RBUTTONDOWN:
- case WM_LBUTTONUP:
- case WM_LBUTTONDBLCLK:
- m_pLog->SendMsg(EM_EXGETSEL, 0, (LPARAM)&sel);
- if (sel.cpMin != sel.cpMax)
- break;
-
- CMStringW wszText(' ', pLink->chrg.cpMax - pLink->chrg.cpMin + 1);
- {
+ switch (msg) {
+ case WM_NOTIFY:
+ if (m_pLog != nullptr) {
+ LPNMHDR hdr = (LPNMHDR)lParam;
+ if (hdr->hwndFrom == m_pLog->GetHwnd() && hdr->code == EN_LINK) {
+ ENLINK *pLink = (ENLINK*)lParam;
+ switch (pLink->msg) {
+ case WM_SETCURSOR:
+ SetCursor(g_hCurHyperlinkHand);
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, TRUE);
+ return TRUE;
+
+ case WM_RBUTTONDOWN:
+ case WM_LBUTTONUP:
+ case WM_LBUTTONDBLCLK:
+ CHARRANGE sel;
+ m_pLog->SendMsg(EM_EXGETSEL, 0, (LPARAM)&sel);
+ if (sel.cpMin != sel.cpMax)
+ break;
+
+ CMStringW wszText(' ', pLink->chrg.cpMax - pLink->chrg.cpMin + 1);
+
TEXTRANGE tr;
tr.chrg = pLink->chrg;
tr.lpstrText = wszText.GetBuffer();
m_pLog->SendMsg(EM_GETTEXTRANGE, 0, (LPARAM)&tr);
if (wcschr(tr.lpstrText, '@') != NULL && wcschr(tr.lpstrText, ':') == NULL && wcschr(tr.lpstrText, '/') == NULL)
wszText.Insert(0, L"mailto:");
- }
-
- if (pLink->msg == WM_RBUTTONDOWN) {
- HMENU hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_CONTEXT));
- HMENU hSubMenu = GetSubMenu(hMenu, 6);
- TranslateMenu(hSubMenu);
-
- POINT pt = { GET_X_LPARAM(pLink->lParam), GET_Y_LPARAM(pLink->lParam) };
- ClientToScreen(((NMHDR *)lParam)->hwndFrom, &pt);
-
- switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, m_hwnd, NULL)) {
- case IDM_OPENLINK:
- Utils_OpenUrlW(wszText);
- break;
- case IDM_COPYLINK:
- if (OpenClipboard(m_hwnd)) {
- EmptyClipboard();
- HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE, (wszText.GetLength()+1) * sizeof(wchar_t));
- mir_wstrcpy((wchar_t*)GlobalLock(hData), wszText);
- GlobalUnlock(hData);
- SetClipboardData(CF_UNICODETEXT, hData);
- CloseClipboard();
+ if (pLink->msg == WM_RBUTTONDOWN) {
+ HMENU hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_CONTEXT));
+ HMENU hSubMenu = GetSubMenu(hMenu, 6);
+ TranslateMenu(hSubMenu);
+
+ POINT pt = { GET_X_LPARAM(pLink->lParam), GET_Y_LPARAM(pLink->lParam) };
+ ClientToScreen(((NMHDR *)lParam)->hwndFrom, &pt);
+
+ switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, m_hwnd, NULL)) {
+ case IDM_OPENLINK:
+ Utils_OpenUrlW(wszText);
+ break;
+
+ case IDM_COPYLINK:
+ if (OpenClipboard(m_hwnd)) {
+ EmptyClipboard();
+ HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE, (wszText.GetLength() + 1) * sizeof(wchar_t));
+ mir_wstrcpy((wchar_t*)GlobalLock(hData), wszText);
+ GlobalUnlock(hData);
+ SetClipboardData(CF_UNICODETEXT, hData);
+ CloseClipboard();
+ }
+ break;
}
- break;
+
+ DestroyMenu(hMenu);
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, TRUE);
+ return TRUE;
}
- DestroyMenu(hMenu);
- SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, TRUE);
- return TRUE;
+ Utils_OpenUrlW(wszText);
+ if (m_pEntry != nullptr)
+ SetFocus(m_pEntry->GetHwnd());
}
-
- Utils_OpenUrlW(wszText);
- if (m_pEntry != nullptr)
- SetFocus(m_pEntry->GetHwnd());
}
}
+ break;
}
return CDlgBase::DlgProc(msg, wParam, lParam);
}
+
+void CSrmmBaseDialog::DoEventHook(int iType, const USERINFO *pUser, const wchar_t *pszText, INT_PTR dwItem)
+{
+ GCDEST gcd = {};
+ gcd.pszModule = m_si->pszModule;
+ gcd.ptszID = m_si->ptszID;
+ gcd.iType = iType;
+
+ GCHOOK gch = {};
+ if (pUser != nullptr) {
+ gch.ptszUID = pUser->pszUID;
+ gch.ptszNick = pUser->pszNick;
+ }
+
+ gch.ptszText = (LPWSTR)pszText;
+ gch.dwData = dwItem;
+ gch.pDest = &gcd;
+ NotifyEventHooks(chatApi.hSendEvent, 0, (WPARAM)&gch);
+}