diff options
author | George Hazan <george.hazan@gmail.com> | 2014-05-04 21:52:21 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-05-04 21:52:21 +0000 |
commit | f7a344dab108224cc2dcb1e39eba5b41efcadefd (patch) | |
tree | 7d9494defc5e2aa352701e6c7f53c4b8391c53ac | |
parent | cc47930b9ea9ccb12f356c35e5a438985bd8fa76 (diff) |
- duplicated code removed
git-svn-id: http://svn.miranda-ng.org/main/trunk@9130 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/Scriver/src/msgs.cpp | 61 |
1 files changed, 25 insertions, 36 deletions
diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index 8ca0b613d7..738d552810 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -137,67 +137,56 @@ static int MessageEventAdded(WPARAM hContact, LPARAM lParam) return 0;
}
-static INT_PTR SendMessageCommandW(WPARAM hContact, LPARAM lParam)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static INT_PTR SendMessageCommandWorker(MCONTACT hContact, LPCSTR pszMsg, bool isWchar)
{
- /* does the MCONTACT's protocol support IM messages? */
+ if (db_mc_isSub(hContact))
+ hContact = db_mc_getMeta(hContact);
+
+ /* does the MCONTACT's protocol support IM messages? */
char *szProto = GetContactProto(hContact);
- if (szProto == NULL)
- return 1; /* unknown contact */
+ if (szProto == NULL)
+ return 1; /* unknown contact */
if (!CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND)
return 1;
HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, hContact);
if (hwnd != NULL) {
- if (lParam) {
+ if (pszMsg) {
HWND hEdit = GetDlgItem(hwnd, IDC_MESSAGE);
SendMessage(hEdit, EM_SETSEL, -1, SendMessage(hEdit, WM_GETTEXTLENGTH, 0, 0));
- SendMessage(hEdit, EM_REPLACESEL, FALSE, (LPARAM)(TCHAR *) lParam);
+ if (isWchar)
+ SendMessageW(hEdit, EM_REPLACESEL, FALSE, (LPARAM)pszMsg);
+ else
+ SendMessageA(hEdit, EM_REPLACESEL, FALSE, (LPARAM)pszMsg);
}
SendMessage(GetParent(hwnd), CM_POPUPWINDOW, 0, (LPARAM)hwnd);
}
else {
NewMessageWindowLParam newData = { 0 };
newData.hContact = hContact;
- newData.szInitialText = (const char *) lParam;
- newData.isWchar = 1;
+ newData.szInitialText = pszMsg;
+ newData.isWchar = isWchar;
HWND hParent = GetParentWindow(newData.hContact, FALSE);
- CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), hParent, DlgProcMessage, (LPARAM)& newData);
+ CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), hParent, DlgProcMessage, (LPARAM)&newData);
}
return 0;
}
-static INT_PTR SendMessageCommand(WPARAM hContact, LPARAM lParam)
+static INT_PTR SendMessageCommandW(WPARAM hContact, LPARAM lParam)
{
- char *szProto = GetContactProto(hContact);
- //logInfo("Show message window for: %s (%s)", CallService(MS_CLIST_GETCONTACTDISPLAYNAME, wParam, 0), szProto);
- if (szProto) {
- /* does the MCONTACT's protocol support IM messages? */
- if (!CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND)
- return 1;
- }
- else /* unknown contact */
- return 1;
+ return SendMessageCommandWorker(hContact, LPCSTR(lParam), true);
+}
- HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, hContact);
- if (hwnd != NULL) {
- if (lParam) {
- HWND hEdit = GetDlgItem(hwnd, IDC_MESSAGE);
- SendMessage(hEdit, EM_SETSEL, -1, SendMessage(hEdit, WM_GETTEXTLENGTH, 0, 0));
- SendMessageA(hEdit, EM_REPLACESEL, FALSE, (LPARAM)(char*) lParam);
- }
- SendMessage(GetParent(hwnd), CM_POPUPWINDOW, 0, (LPARAM)hwnd);
- }
- else {
- NewMessageWindowLParam newData = { 0 };
- newData.hContact = hContact;
- newData.szInitialText = (const char *)lParam;
- HWND hParent = GetParentWindow(newData.hContact, FALSE);
- CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), hParent, DlgProcMessage, (LPARAM)& newData);
- }
- return 0;
+static INT_PTR SendMessageCommand(WPARAM hContact, LPARAM lParam)
+{
+ return SendMessageCommandWorker(hContact, LPCSTR(lParam), false);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
static INT_PTR TypingMessageCommand(WPARAM wParam, LPARAM lParam)
{
CLISTEVENT *cle = (CLISTEVENT*)lParam;
|