summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2016-09-17 16:37:24 +0000
committerGeorge Hazan <george.hazan@gmail.com>2016-09-17 16:37:24 +0000
commite5d58fc3bbbce2773b7c6c3f8b7da6faa66b672e (patch)
tree6432409a59b53d8098ac38aa1d3072ae2e5f9e4b /plugins
parent17e345e621254103a98bbc7e662a2829b7aa3ce6 (diff)
chats: more functions, less structures
git-svn-id: http://svn.miranda-ng.org/main/trunk@17309 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Dropbox/src/dropbox_utils.cpp9
-rw-r--r--plugins/MirLua/src/m_message.cpp14
-rw-r--r--plugins/MirandaG15/src/CAppletManager.cpp61
-rw-r--r--plugins/PasteIt/src/PasteIt.cpp12
-rw-r--r--plugins/Scriver/src/chat/main.cpp2
-rw-r--r--plugins/Scriver/src/chat/window.cpp11
-rw-r--r--plugins/SendScreenshotPlus/src/CSend.cpp11
-rw-r--r--plugins/TabSRMM/src/chat/main.cpp2
-rw-r--r--plugins/TabSRMM/src/chat/window.cpp11
9 files changed, 40 insertions, 93 deletions
diff --git a/plugins/Dropbox/src/dropbox_utils.cpp b/plugins/Dropbox/src/dropbox_utils.cpp
index d615b33ea0..0589cddc35 100644
--- a/plugins/Dropbox/src/dropbox_utils.cpp
+++ b/plugins/Dropbox/src/dropbox_utils.cpp
@@ -106,14 +106,7 @@ void CDropbox::SendToContact(MCONTACT hContact, const wchar_t *data)
const char *szProto = GetContactProto(hContact);
if (db_get_b(hContact, szProto, "ChatRoom", 0) == TRUE) {
ptrW tszChatRoom(db_get_wsa(hContact, szProto, "ChatRoomID"));
- GCDEST gcd = { szProto, tszChatRoom, GC_EVENT_SENDMESSAGE };
- GCEVENT gce = { sizeof(gce), &gcd };
- gce.bIsMe = TRUE;
- gce.dwFlags = GCEF_ADDTOLOG;
- gce.ptszText = mir_wstrdup(data);
- gce.time = time(NULL);
- Chat_Event(WINDOW_VISIBLE, &gce);
- mir_free((void*)gce.ptszText);
+ Chat_SendUserMessage(szProto, tszChatRoom, data);
return;
}
diff --git a/plugins/MirLua/src/m_message.cpp b/plugins/MirLua/src/m_message.cpp
index cc0de69657..d08fad864b 100644
--- a/plugins/MirLua/src/m_message.cpp
+++ b/plugins/MirLua/src/m_message.cpp
@@ -34,18 +34,10 @@ static int message_Send(lua_State *L)
const char *szProto = GetContactProto(hContact);
if (db_get_b(hContact, szProto, "ChatRoom", 0) == TRUE)
{
- ptrW tszChatRoom(db_get_wsa(hContact, szProto, "ChatRoomID"));
- GCDEST gcd = { szProto, tszChatRoom, GC_EVENT_SENDMESSAGE };
- GCEVENT gce = { sizeof(gce), &gcd };
- gce.bIsMe = TRUE;
- gce.dwFlags = GCEF_ADDTOLOG;
- gce.ptszText = mir_utf8decodeW(message);
- gce.time = time(NULL);
-
- res = Chat_Event(WINDOW_VISIBLE, &gce);
+ ptrW wszChatRoom(db_get_wsa(hContact, szProto, "ChatRoomID"));
+ ptrW wszMessage(mir_utf8decodeW(message));
+ res = Chat_SendUserMessage(szProto, wszChatRoom, wszMessage);
lua_pushinteger(L, res);
-
- mir_free((void*)gce.ptszText);
}
else if ((res = ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)message)) != ACKRESULT_FAILED)
{
diff --git a/plugins/MirandaG15/src/CAppletManager.cpp b/plugins/MirandaG15/src/CAppletManager.cpp
index f7030c03a8..b6755f5dca 100644
--- a/plugins/MirandaG15/src/CAppletManager.cpp
+++ b/plugins/MirandaG15/src/CAppletManager.cpp
@@ -757,44 +757,31 @@ MEVENT CAppletManager::SendMessageToContact(MCONTACT hContact, tstring strMessag
CIRCConnection *pIRCCon = CAppletManager::GetInstance()->GetIRCConnection(strProto);
if (pIRCCon && db_get_b(hContact, szProto, "ChatRoom", 0) != 0) {
- DBVARIANT dbv;
- if (db_get_ws(hContact, szProto, "Nick", &dbv))
+ ptrW wszNick(db_get_wsa(hContact, szProto, "Nick"));
+ if (wszNick == NULL)
return NULL;
- GCDEST gcd = { szProto, 0, GC_EVENT_SENDMESSAGE };
- gcd.ptszID = dbv.ptszVal;
-
- tstring strID = tstring(gcd.ptszID) + L" - " + tstring(_A2T(toNarrowString(pIRCCon->strNetwork).c_str()));
- gcd.ptszID = (LPTSTR)strID.c_str();
-
- GCEVENT gce = { sizeof(gce), &gcd };
- gce.ptszStatus = L"";
- gce.ptszText = (LPTSTR)strAscii.c_str();
- gce.time = time(NULL);
- gce.bIsMe = true;
- Chat_Event(NULL, &gce);
-
- db_free(&dbv);
+ tstring strID = tstring(wszNick) + L" - " + tstring(_A2T(toNarrowString(pIRCCon->strNetwork).c_str()));
+ Chat_SendUserMessage(szProto, strID.c_str(), strAscii.c_str());
return 0;
}
- else {
- SMessageJob *pJob = new SMessageJob();
- pJob->dwTimestamp = GetTickCount();
- pJob->hContact = hContact;
- char* szMsgUtf = mir_utf8encodeW(strMessage.c_str());
+ SMessageJob *pJob = new SMessageJob();
+ pJob->dwTimestamp = GetTickCount();
+ pJob->hContact = hContact;
- pJob->iBufferSize = (int)mir_strlen(szMsgUtf) + 1;
- pJob->pcBuffer = (char *)malloc(pJob->iBufferSize);
- pJob->dwFlags = 0;
+ char* szMsgUtf = mir_utf8encodeW(strMessage.c_str());
- memcpy(pJob->pcBuffer, szMsgUtf, pJob->iBufferSize);
- mir_free(szMsgUtf);
+ pJob->iBufferSize = (int)mir_strlen(szMsgUtf) + 1;
+ pJob->pcBuffer = (char *)malloc(pJob->iBufferSize);
+ pJob->dwFlags = 0;
- pJob->hEvent = (MEVENT)ProtoChainSend(pJob->hContact, PSS_MESSAGE, 0, (LPARAM)pJob->pcBuffer);
- CAppletManager::GetInstance()->AddMessageJob(pJob);
- return pJob->hEvent;
- }
+ memcpy(pJob->pcBuffer, szMsgUtf, pJob->iBufferSize);
+ mir_free(szMsgUtf);
+
+ pJob->hEvent = (MEVENT)ProtoChainSend(pJob->hContact, PSS_MESSAGE, 0, (LPARAM)pJob->pcBuffer);
+ CAppletManager::GetInstance()->AddMessageJob(pJob);
+ return pJob->hEvent;
}
//************************************************************************
@@ -1126,13 +1113,13 @@ int CAppletManager::HookChatInbound(WPARAM, LPARAM lParam)
}
// fetch the network name
- if (gcd->iType == GC_EVENT_CHANGESESSIONAME) {
- if (gcd->ptszID && !mir_wstrcmpi(gcd->ptszID, L"Network log")) {
- pIRCCon->strNetwork = toTstring(gce->ptszText);
- TRACE(L"\t Found network identifier: %s\n", pIRCCon->strNetwork.c_str());
- return 0;
- }
- }
+ // if (gcd->iType == GC_EVENT_CHANGESESSIONAME) {
+ // if (gcd->ptszID && !mir_wstrcmpi(gcd->ptszID, L"Network log")) {
+ // pIRCCon->strNetwork = toTstring(gce->ptszText);
+ // TRACE(L"\t Found network identifier: %s\n", pIRCCon->strNetwork.c_str());
+ // return 0;
+ // }
+ // }
CEvent Event;
if (gce->bIsMe)
diff --git a/plugins/PasteIt/src/PasteIt.cpp b/plugins/PasteIt/src/PasteIt.cpp
index 6b6a8bd599..c5e08928b4 100644
--- a/plugins/PasteIt/src/PasteIt.cpp
+++ b/plugins/PasteIt/src/PasteIt.cpp
@@ -144,12 +144,10 @@ void PasteIt(MCONTACT hContact, int mode)
// in chat room.
// Next step is to get all protocol sessions and find
// one with correct hContact
- GC_INFO gci = { 0 };
- GCDEST gcd = { szProto, NULL, GC_EVENT_SENDMESSAGE };
- GCEVENT gce = { sizeof(gce), &gcd };
int cnt = pci->SM_GetCount(szProto);
for (int i = 0; i < cnt; i++)
{
+ GC_INFO gci = {};
gci.iItem = i;
gci.pszModule = szProto;
gci.Flags = GCF_BYINDEX | GCF_HCONTACT | GCF_ID;
@@ -159,13 +157,7 @@ void PasteIt(MCONTACT hContact, int mode)
// In this place session was finded, gci.pszID contains
// session ID, but it is in unicode or ascii format,
// depends on protocol wersion
- gcd.ptszID = gci.pszID;
- gce.bIsMe = TRUE;
- gce.dwFlags = GCEF_ADDTOLOG;
- gce.ptszText = mir_a2u_cp(pasteToWeb->szFileLink, CP_ACP);
- gce.time = time(NULL);
- Chat_Event(0, &gce);
- mir_free((void*)gce.ptszText);
+ Chat_SendUserMessage(szProto, gci.pszID, _A2T(pasteToWeb->szFileLink));
break;
}
}
diff --git a/plugins/Scriver/src/chat/main.cpp b/plugins/Scriver/src/chat/main.cpp
index cff8723cf0..06b0235d2b 100644
--- a/plugins/Scriver/src/chat/main.cpp
+++ b/plugins/Scriver/src/chat/main.cpp
@@ -61,7 +61,7 @@ static void OnDblClickSession(SESSION_INFO *si)
static void OnRemoveSession(SESSION_INFO *si)
{
if (si->hWnd)
- SendMessage(si->hWnd, GC_EVENT_CONTROL + WM_USER + 500, SESSION_TERMINATE, 0);
+ SendMessage(si->hWnd, GC_CONTROL_MSG, SESSION_TERMINATE, 0);
}
static void OnRenameSession(SESSION_INFO *si)
diff --git a/plugins/Scriver/src/chat/window.cpp b/plugins/Scriver/src/chat/window.cpp
index 263d504ced..461cb94a2c 100644
--- a/plugins/Scriver/src/chat/window.cpp
+++ b/plugins/Scriver/src/chat/window.cpp
@@ -1266,7 +1266,7 @@ static INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPAR
}
else Log_StreamInEvent(hwndDlg, si->pLogEnd, si, TRUE);
}
- else SendMessage(hwndDlg, GC_EVENT_CONTROL + WM_USER + 500, WINDOW_CLEARLOG, 0);
+ else SendMessage(hwndDlg, GC_CONTROL_MSG, WINDOW_CLEARLOG, 0);
break;
case GC_REDRAWLOG2:
@@ -1285,7 +1285,7 @@ static INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPAR
if (si->pLogEnd)
Log_StreamInEvent(hwndDlg, si->pLog, si, FALSE);
else
- SendMessage(hwndDlg, GC_EVENT_CONTROL + WM_USER + 500, WINDOW_CLEARLOG, 0);
+ SendMessage(hwndDlg, GC_CONTROL_MSG, WINDOW_CLEARLOG, 0);
break;
case DM_UPDATETABCONTROL:
@@ -1343,11 +1343,6 @@ static INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPAR
}
break;
- case GC_ACKMESSAGE:
- SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_SETREADONLY, FALSE, 0);
- SetDlgItemText(hwndDlg, IDC_CHAT_MESSAGE, L"");
- return TRUE;
-
case WM_CTLCOLORLISTBOX:
SetBkColor((HDC)wParam, g_Settings.crUserListBGColor);
return (INT_PTR)pci->hListBkgBrush;
@@ -1440,7 +1435,7 @@ static INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPAR
SendMessage(hwndDlg, DM_UPDATETITLEBAR, 0, 0);
break;
- case GC_EVENT_CONTROL + WM_USER + 500:
+ case GC_CONTROL_MSG:
switch (wParam) {
case SESSION_OFFLINE:
SendMessage(hwndDlg, DM_UPDATESTATUSBAR, 0, 0);
diff --git a/plugins/SendScreenshotPlus/src/CSend.cpp b/plugins/SendScreenshotPlus/src/CSend.cpp
index d80b7a016b..618ceca12c 100644
--- a/plugins/SendScreenshotPlus/src/CSend.cpp
+++ b/plugins/SendScreenshotPlus/src/CSend.cpp
@@ -231,15 +231,8 @@ void CSend::svcSendMsgExit(const char* szMessage)
gci.Flags = GCF_BYINDEX | GCF_HCONTACT | GCF_ID;
Chat_GetInfo(&gci);
if (gci.hContact == m_hContact) {
- GCDEST gcd = { m_pszProto, gci.pszID, GC_EVENT_SENDMESSAGE };
- GCEVENT gce = { sizeof(gce), &gcd };
- gce.bIsMe = TRUE;
- gce.dwFlags = GCEF_ADDTOLOG;
- gce.ptszText = tmp;
- gce.time = time(NULL);
-
- //* returns 0 on success or error code on failure
- res = 200 + (int)Chat_Event(0, &gce);
+ Chat_SendUserMessage(m_pszProto, gci.pszID, tmp);
+ res = 200;
break;
}
}
diff --git a/plugins/TabSRMM/src/chat/main.cpp b/plugins/TabSRMM/src/chat/main.cpp
index e3005afb9f..e55c8d3082 100644
--- a/plugins/TabSRMM/src/chat/main.cpp
+++ b/plugins/TabSRMM/src/chat/main.cpp
@@ -61,7 +61,7 @@ static void OnDblClickSession(SESSION_INFO *si)
static void OnRemoveSession(SESSION_INFO *si)
{
if (si->hWnd)
- SendMessage(si->hWnd, GC_EVENT_CONTROL + WM_USER + 500, SESSION_TERMINATE, 0);
+ SendMessage(si->hWnd, GC_CONTROL_MSG, SESSION_TERMINATE, 0);
}
static void OnRenameSession(SESSION_INFO *si)
diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp
index 289763089e..d44c0bb5b6 100644
--- a/plugins/TabSRMM/src/chat/window.cpp
+++ b/plugins/TabSRMM/src/chat/window.cpp
@@ -2058,7 +2058,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
}
else Log_StreamInEvent(hwndDlg, si->pLogEnd, si, TRUE);
}
- else SendMessage(hwndDlg, GC_EVENT_CONTROL + WM_USER + 500, WINDOW_CLEARLOG, 0);
+ else SendMessage(hwndDlg, GC_CONTROL_MSG, WINDOW_CLEARLOG, 0);
break;
case GC_REDRAWLOG2:
@@ -2089,14 +2089,9 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
if (si->pLogEnd)
Log_StreamInEvent(hwndDlg, si->pLog, si, FALSE);
else
- SendMessage(hwndDlg, GC_EVENT_CONTROL + WM_USER + 500, WINDOW_CLEARLOG, 0);
+ SendMessage(hwndDlg, GC_CONTROL_MSG, WINDOW_CLEARLOG, 0);
break;
- case GC_ACKMESSAGE:
- SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_SETREADONLY, FALSE, 0);
- SetDlgItemText(hwndDlg, IDC_CHAT_MESSAGE, L"");
- return TRUE;
-
case DM_TYPING:
// Typing support for GCW_PRIVMESS sessions
if (si->iType == GCW_PRIVMESS) {
@@ -2247,7 +2242,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
}
break;
- case GC_EVENT_CONTROL + WM_USER + 500:
+ case GC_CONTROL_MSG:
switch (wParam) {
case SESSION_OFFLINE:
SendMessage(hwndDlg, GC_UPDATESTATUSBAR, 0, 0);