From 122baf7f7465e0b5b890729d65914f527db1ca26 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 17 Jun 2012 14:07:44 +0000 Subject: Unicode ACKTYPE_AWAYMSG broadcast git-svn-id: http://svn.miranda-ng.org/main/trunk@458 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/SimpleStatusMsg/awaymsg.cpp | 61 ++++++++----------------------------- 1 file changed, 12 insertions(+), 49 deletions(-) (limited to 'plugins/SimpleStatusMsg') diff --git a/plugins/SimpleStatusMsg/awaymsg.cpp b/plugins/SimpleStatusMsg/awaymsg.cpp index 5aebe1edb1..705b860cc5 100644 --- a/plugins/SimpleStatusMsg/awaymsg.cpp +++ b/plugins/SimpleStatusMsg/awaymsg.cpp @@ -137,28 +137,12 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP if (ack->result != ACKRESULT_SUCCESS) break; if (dat->hAwayMsgEvent && ack->hProcess == dat->hSeq) { UnhookEvent(dat->hAwayMsgEvent); dat->hAwayMsgEvent = NULL; } + TCHAR *tszMsg = StrNormNewline((TCHAR*)ack->lParam); + SetDlgItemText(hwndDlg, IDC_MSG, tszMsg); + mir_free(tszMsg); - DBVARIANT dbv; - bool unicode = !DBGetContactSetting(dat->hContact, "CList", "StatusMsg", &dbv) && - (dbv.type == DBVT_UTF8 || dbv.type == DBVT_WCHAR); - DBFreeVariant(&dbv); - if (unicode) - { - DBGetContactSettingWString(dat->hContact, "CList", "StatusMsg", &dbv); - TCHAR *tszMsg = StrNormNewline(dbv.pwszVal); - SetDlgItemText(hwndDlg, IDC_MSG, tszMsg); - mir_free(tszMsg); - DBFreeVariant(&dbv); - } - else - - { - char *szMsg = StrNormNewlineA((char *)ack->lParam); - SetDlgItemTextA(hwndDlg, IDC_MSG, szMsg); - mir_free(szMsg); - } - - if (ack->lParam && *((char*)ack->lParam) != '\0') EnableWindow(GetDlgItem(hwndDlg, IDC_COPY), TRUE); + if (ack->lParam && *((char*)ack->lParam) != '\0') + EnableWindow(GetDlgItem(hwndDlg, IDC_COPY), TRUE); ShowWindow(GetDlgItem(hwndDlg, IDC_RETRIEVING), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_MSG), SW_SHOW); SetDlgItemText(hwndDlg, IDOK, TranslateT("&Close")); @@ -257,7 +241,7 @@ static INT_PTR CALLBACK CopyAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP } case HM_AWAYMSG: - { + { ACKDATA *ack = (ACKDATA*)lParam; if (ack->hContact != dat->hContact || ack->type != ACKTYPE_AWAYMSG) { DestroyWindow(hwndDlg); break; } if (ack->result != ACKRESULT_SUCCESS) { DestroyWindow(hwndDlg); break; } @@ -267,35 +251,15 @@ static INT_PTR CALLBACK CopyAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP if (EmptyClipboard()) { TCHAR msg[1024]; - int len; - - DBVARIANT dbv; - bool unicode = !DBGetContactSetting(dat->hContact, "CList", "StatusMsg", &dbv) && - (dbv.type == DBVT_UTF8 || dbv.type == DBVT_WCHAR); - DBFreeVariant(&dbv); - if (unicode) - { - DBGetContactSettingWString(dat->hContact, "CList", "StatusMsg", &dbv); - TCHAR *tszMsg = StrNormNewline(dbv.pwszVal); - mir_sntprintf(msg, SIZEOF(msg), _T("%s"), tszMsg); - mir_free(tszMsg); - DBFreeVariant(&dbv); - } - else - - { - char *szMsg = StrNormNewlineA((char *)ack->lParam); - mir_sntprintf(msg, SIZEOF(msg), _T("%hs"), szMsg); - mir_free(szMsg); - } - len = lstrlen(msg); - + TCHAR *tszMsg = StrNormNewline((TCHAR*)ack->lParam); + mir_sntprintf(msg, SIZEOF(msg), _T("%s"), tszMsg); + mir_free(tszMsg); + size_t len = lstrlen(msg); if (len) { LPTSTR lptstrCopy; HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (len + 1) * sizeof(TCHAR)); - if (hglbCopy == NULL) - { + if (hglbCopy == NULL) { CloseClipboard(); DestroyWindow(hwndDlg); break; @@ -306,7 +270,6 @@ static INT_PTR CALLBACK CopyAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP GlobalUnlock(hglbCopy); SetClipboardData(CF_UNICODETEXT, hglbCopy); - } } CloseClipboard(); @@ -362,7 +325,7 @@ static char *StrFindURL(char *pszStr) if (pszURL == NULL) pszURL = strstr(pszStr, "ftp://"); } - + return pszURL; } -- cgit v1.2.3