From 4d7fb80e18aa7b131bae7a0a55efb5d4a5097866 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 17 May 2016 15:38:59 +0000 Subject: Scriver: - fix for toolbar icons; - horror with buffers replaced with CMString; - unused code removed; git-svn-id: http://svn.miranda-ng.org/main/trunk@16839 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Scriver/src/globals.cpp | 26 +++++---- plugins/Scriver/src/infobar.cpp | 43 +++++++-------- plugins/Scriver/src/msgdialog.cpp | 25 ++++----- plugins/Scriver/src/msglog.cpp | 50 +---------------- plugins/Scriver/src/msgs.cpp | 7 +-- plugins/Scriver/src/msgs.h | 1 - plugins/Scriver/src/msgwindow.cpp | 113 ++++++++++---------------------------- plugins/Scriver/src/msgwindow.h | 1 - plugins/Scriver/src/sendqueue.cpp | 2 +- plugins/Scriver/src/utils.cpp | 31 ----------- plugins/Scriver/src/utils.h | 1 - 11 files changed, 83 insertions(+), 217 deletions(-) diff --git a/plugins/Scriver/src/globals.cpp b/plugins/Scriver/src/globals.cpp index 4de574d6f3..78259fb1ef 100644 --- a/plugins/Scriver/src/globals.cpp +++ b/plugins/Scriver/src/globals.cpp @@ -27,15 +27,18 @@ GlobalMessageData g_dat; int Chat_ModulesLoaded(WPARAM wParam,LPARAM lParam); -static const char *buttonIcons[] = {"scriver_CLOSEX", "scriver_QUOTE", "scriver_SMILEY", - "scriver_ADD", NULL, "scriver_USERDETAILS", "scriver_HISTORY", - "scriver_SEND"}; +static const char *buttonIcons[] = +{ + "scriver_CLOSEX", "scriver_QUOTE", "scriver_ADD", NULL, + "scriver_USERDETAILS", "scriver_HISTORY", "scriver_SEND" +}; -static const char *chatButtonIcons[] = {"scriver_CLOSEX", - "chat_bold", "chat_italics", "chat_underline", - "chat_fgcol", "chat_bkgcol", - "chat_smiley", "chat_history", - "chat_filter", "chat_settings", "chat_nicklist", "scriver_SEND"}; +static const char *chatButtonIcons[] = +{ + "scriver_CLOSEX", "chat_bold", "chat_italics", "chat_underline", + "chat_fgcol", "chat_bkgcol", "chat_history", "chat_filter", + "chat_settings", "chat_nicklist", "scriver_SEND" +}; static IconItem iconList[] = { @@ -125,13 +128,14 @@ static int ackevent(WPARAM, LPARAM lParam) if (item != NULL && item->hwndErrorDlg == NULL) { if (hwndSender != NULL) { - ErrorWindowData *ewd = (ErrorWindowData *)mir_alloc(sizeof(ErrorWindowData)); - ewd->szName = GetNickname(item->hContact, item->proto); + SendMessage(hwndSender, DM_STOPMESSAGESENDING, 0, 0); + + ErrorWindowData *ewd = (ErrorWindowData*)mir_alloc(sizeof(ErrorWindowData)); + ewd->szName = mir_tstrdup(pcli->pfnGetContactDisplayName(item->hContact, 0)); ewd->szDescription = mir_a2t((char *)pAck->lParam); ewd->szText = GetSendBufferMsg(item); ewd->hwndParent = hwndSender; ewd->queueItem = item; - SendMessage(hwndSender, DM_STOPMESSAGESENDING, 0, 0); SendMessage(hwndSender, DM_SHOWERRORMESSAGE, 0, (LPARAM)ewd); } else RemoveSendQueueItem(item); diff --git a/plugins/Scriver/src/infobar.cpp b/plugins/Scriver/src/infobar.cpp index 27056201bd..83c7fc074b 100644 --- a/plugins/Scriver/src/infobar.cpp +++ b/plugins/Scriver/src/infobar.cpp @@ -25,14 +25,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void SetupInfobar(InfobarWindowData* idat) { - HWND hwnd = idat->hWnd; - CHARFORMAT2 cf2; - memset(&cf2, 0, sizeof(cf2)); - LOGFONT lf; DWORD colour = db_get_dw(NULL, SRMMMOD, SRMSGSET_INFOBARBKGCOLOUR, SRMSGDEFSET_INFOBARBKGCOLOUR); + + HWND hwnd = idat->hWnd; SendDlgItemMessage(hwnd, IDC_INFOBAR_NAME, EM_SETBKGNDCOLOR, 0, colour); SendDlgItemMessage(hwnd, IDC_INFOBAR_STATUS, EM_SETBKGNDCOLOR, 0, colour); + + LOGFONT lf; LoadMsgDlgFont(MSGFONTID_INFOBAR_NAME, &lf, &colour); + + CHARFORMAT2 cf2; + memset(&cf2, 0, sizeof(cf2)); cf2.dwMask = CFM_COLOR | CFM_FACE | CFM_CHARSET | CFM_SIZE | CFM_WEIGHT | CFM_BOLD | CFM_ITALIC; cf2.cbSize = sizeof(cf2); cf2.crTextColor = colour; @@ -67,7 +70,7 @@ static HICON GetExtraStatusIcon(InfobarWindowData* idat) { BYTE bXStatus = db_get_b(idat->mwd->hContact, idat->mwd->szProto, "XStatusId", 0); if (bXStatus > 0) - return (HICON) CallProtoService(idat->mwd->szProto, PS_GETCUSTOMSTATUSICON, bXStatus, 0); + return (HICON)CallProtoService(idat->mwd->szProto, PS_GETCUSTOMSTATUSICON, bXStatus, 0); return NULL; } @@ -76,34 +79,28 @@ void RefreshInfobar(InfobarWindowData* idat) { HWND hwnd = idat->hWnd; SrmmWindowData *dat = idat->mwd; - TCHAR *szContactName = GetNickname(dat->hContact, dat->szProto); - TCHAR *szContactStatusMsg = db_get_tsa(dat->hContact, "CList", "StatusMsg"); - TCHAR *szXStatusName = db_get_tsa(idat->mwd->hContact, idat->mwd->szProto, "XStatusName"); - TCHAR *szXStatusMsg = db_get_tsa(idat->mwd->hContact, idat->mwd->szProto, "XStatusMsg"); + ptrT szContactStatusMsg(db_get_tsa(dat->hContact, "CList", "StatusMsg")); + ptrT szXStatusName(db_get_tsa(idat->mwd->hContact, idat->mwd->szProto, "XStatusName")); + ptrT szXStatusMsg(db_get_tsa(idat->mwd->hContact, idat->mwd->szProto, "XStatusMsg")); HICON hIcon = GetExtraStatusIcon(idat); TCHAR szText[2048]; SETTEXTEX st; - if ( szXStatusMsg && *szXStatusMsg ) + if (szXStatusMsg && *szXStatusMsg) mir_sntprintf(szText, _T("%s (%s)"), TranslateTS(szXStatusName), szXStatusMsg); else _tcsncpy_s(szText, TranslateTS(szXStatusName), _TRUNCATE); st.flags = ST_DEFAULT; st.codepage = 1200; - SendDlgItemMessage(hwnd, IDC_INFOBAR_NAME, EM_SETTEXTEX, (WPARAM)&st, (LPARAM)szContactName); + SendDlgItemMessage(hwnd, IDC_INFOBAR_NAME, EM_SETTEXTEX, (WPARAM)&st, (LPARAM)pcli->pfnGetContactDisplayName(dat->hContact, 0)); SendDlgItemMessage(hwnd, IDC_INFOBAR_STATUS, EM_SETTEXTEX, (WPARAM)&st, (LPARAM)szContactStatusMsg); hIcon = (HICON)SendDlgItemMessage(hwnd, IDC_XSTATUSICON, STM_SETICON, (WPARAM)hIcon, 0); - if (hIcon) { + if (hIcon) DestroyIcon(hIcon); - } + SetToolTipText(hwnd, idat->hXStatusTip, szText, NULL); SendMessage(hwnd, WM_SIZE, 0, 0); InvalidateRect(hwnd, NULL, TRUE); - //RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE); RedrawWindow(GetDlgItem(hwnd, IDC_AVATAR), NULL, NULL, RDW_INVALIDATE); - mir_free(szContactStatusMsg); - mir_free(szContactName); - mir_free(szXStatusName); - mir_free(szXStatusMsg); } static INT_PTR CALLBACK InfobarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) @@ -112,7 +109,7 @@ static INT_PTR CALLBACK InfobarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA InfobarWindowData* idat = (InfobarWindowData *)GetWindowLongPtr(hwnd, GWLP_USERDATA); if (!idat && msg != WM_INITDIALOG) return FALSE; - + switch (msg) { case WM_INITDIALOG: bWasCopy = FALSE; @@ -172,7 +169,7 @@ static INT_PTR CALLBACK InfobarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA case WM_DROPFILES: SendMessage(GetParent(hwnd), WM_DROPFILES, wParam, lParam); - return FALSE; + return FALSE; case WM_NOTIFY: { @@ -223,7 +220,7 @@ static INT_PTR CALLBACK InfobarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA case WM_DRAWITEM: { - LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT) lParam; + LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam; if (dis->hwndItem == GetDlgItem(hwnd, IDC_AVATAR)) { RECT rect; HDC hdcMem = CreateCompatibleDC(dis->hDC); @@ -239,7 +236,7 @@ static INT_PTR CALLBACK InfobarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA if (idat->mwd->avatarPic && (g_dat.flags&SMF_AVATAR)) { BITMAP bminfo; GetObject(idat->mwd->avatarPic, sizeof(bminfo), &bminfo); - if ( bminfo.bmWidth != 0 && bminfo.bmHeight != 0 ) { + if (bminfo.bmWidth != 0 && bminfo.bmHeight != 0) { int avatarHeight = itemHeight; int avatarWidth = bminfo.bmWidth * avatarHeight / bminfo.bmHeight; if (avatarWidth > itemWidth) { @@ -264,7 +261,7 @@ static INT_PTR CALLBACK InfobarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA } } return Menu_DrawItem((LPDRAWITEMSTRUCT)lParam); - + case WM_LBUTTONDOWN: SendMessage(idat->mwd->hwnd, WM_LBUTTONDOWN, wParam, lParam); return TRUE; diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 8f15fc1be7..22b05043b8 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -29,17 +29,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern HCURSOR hCurSplitNS, hCurSplitWE, hCurHyperlinkHand, hDragCursor; extern HANDLE hHookWinEvt; -extern HANDLE hHookWinPopup; static void UpdateReadChars(HWND hwndDlg, SrmmWindowData * dat); -static ToolbarButton toolbarButtons[] = { - {LPGENT("Quote"), IDC_QUOTE, 0, 4, 24}, - {LPGENT("Add contact"), IDC_ADD, 0, 10, 24}, - {LPGENT("User menu"), IDC_USERMENU, 1, 0, 24}, - {LPGENT("User details"), IDC_DETAILS, 1, 0, 24}, - {LPGENT("History"), IDC_HISTORY, 1, 0, 24}, - {LPGENT("Send"), IDOK, 1, 0, 38} +static ToolbarButton toolbarButtons[] = +{ + { LPGENT("Quote"), IDC_QUOTE, 0, 4, 24 }, + { LPGENT("Add contact"), IDC_ADD, 0, 10, 24 }, + { LPGENT("User menu"), IDC_USERMENU, 1, 0, 24 }, + { LPGENT("User details"), IDC_DETAILS, 1, 0, 24 }, + { LPGENT("History"), IDC_HISTORY, 1, 0, 24 }, + { LPGENT("Send"), IDOK, 1, 0, 38 } }; static TCHAR* GetIEViewSelection(SrmmWindowData *dat) @@ -453,7 +453,7 @@ static void SubclassLogEdit(HWND hwnd) static void MessageDialogResize(HWND hwndDlg, SrmmWindowData *dat, int w, int h) { ParentWindowData *pdat = dat->parent; - int hSplitterPos = dat->splitterPos, toolbarHeight = pdat->flags2&SMF2_SHOWTOOLBAR ? IsToolbarVisible(_countof(toolbarButtons), g_dat.buttonVisibility) ? dat->toolbarSize.cy : dat->toolbarSize.cy / 3 : 0; + int hSplitterPos = dat->splitterPos, toolbarHeight = (pdat->flags2 & SMF2_SHOWTOOLBAR) ? IsToolbarVisible(_countof(toolbarButtons), g_dat.buttonVisibility) ? dat->toolbarSize.cy : dat->toolbarSize.cy / 3 : 0; int hSplitterMinTop = toolbarHeight + dat->minLogBoxHeight, hSplitterMinBottom = dat->minEditBoxHeight; int infobarInnerHeight = INFO_BAR_INNER_HEIGHT; int infobarHeight = INFO_BAR_HEIGHT; @@ -1009,9 +1009,8 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP TabControlData tcd; tcd.iFlags = TCDF_TEXT | TCDF_ICON; tcd.hIcon = GetTabIcon(dat); - tcd.pszText = GetTabName(dat->hContact); + tcd.pszText = pcli->pfnGetContactDisplayName(dat->hContact, 0); SendMessage(dat->hwndParent, CM_UPDATETABCONTROL, (WPARAM)&tcd, (LPARAM)hwndDlg); - mir_free(tcd.pszText); break; } @@ -1355,11 +1354,9 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP mir_sntprintf(szText, TranslateT("Sending in progress: %d message(s) left..."), dat->messagesInProgress); } else if (dat->nTypeSecs) { - TCHAR *szContactName = GetNickname(dat->hContact, dat->szProto); sbd.hIcon = GetCachedIcon("scriver_TYPING"); sbd.pszText = szText; - mir_sntprintf(szText, TranslateT("%s is typing a message..."), szContactName); - mir_free(szContactName); + mir_sntprintf(szText, TranslateT("%s is typing a message..."), pcli->pfnGetContactDisplayName(dat->hContact, 0)); dat->nTypeSecs--; } else if (dat->lastMessage) { diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp index 11e5469a30..fb42fa67b5 100644 --- a/plugins/Scriver/src/msglog.cpp +++ b/plugins/Scriver/src/msglog.cpp @@ -84,43 +84,6 @@ struct LogStreamData EventData *events; }; -TCHAR* GetNickname(MCONTACT hContact, const char *szProto) -{ - CONTACTINFO ci = { sizeof(ci) }; - ci.hContact = hContact; - ci.szProto = (char*)szProto; - ci.dwFlag = CNF_DISPLAY; - if (IsUnicodeMIM()) - ci.dwFlag |= CNF_UNICODE; - - TCHAR *szName = NULL; - if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) { - if (ci.type == CNFT_ASCIIZ) { - if (ci.pszVal) { - if (IsUnicodeMIM()) { - if (!mir_tstrcmp((TCHAR*)ci.pszVal, TranslateW(_T("'(Unknown Contact)'")))) { - ci.dwFlag &= ~CNF_UNICODE; - if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) - szName = mir_a2t((char*)ci.pszVal); - } - else szName = mir_tstrdup((TCHAR*)ci.pszVal); - } - else szName = mir_a2t((char*)ci.pszVal); - - mir_free(ci.pszVal); - if (szName != NULL) - return szName; - } - } - } - - TCHAR *tszBaseNick = pcli->pfnGetContactDisplayName(hContact, 0); - if (tszBaseNick != NULL) - return mir_tstrdup(tszBaseNick); - - return mir_tstrdup(TranslateT("Unknown contact")); -} - int DbEventIsCustomForMsgWindow(DBEVENTINFO *dbei) { DBEVENTTYPEDESCR *et = (DBEVENTTYPEDESCR*)CallService(MS_DB_EVENT_GETTYPE, (WPARAM)dbei->szModule, (LPARAM)dbei->eventType); @@ -181,11 +144,7 @@ EventData* getEventFromDB(SrmmWindowData *dat, MCONTACT hContact, MEVENT hDbEven evt->time = dbei.timestamp; evt->pszNick = NULL; - - if (evt->dwFlags & IEEDF_SENT) - evt->pszNickT = GetNickname(NULL, dat->szProto); - else - evt->pszNickT = GetNickname(hContact, dat->szProto); + evt->pszNickT = pcli->pfnGetContactDisplayName((evt->dwFlags & IEEDF_SENT) ? NULL : hContact, 0); if (evt->eventType == EVENTTYPE_FILE) { char *filename = ((char*)dbei.pBlob) + sizeof(DWORD); @@ -217,23 +176,21 @@ static EventData* GetTestEvents() { EventData *evt, *firstEvent, *prevEvent; firstEvent = prevEvent = evt = GetTestEvent(IEEDF_SENT); - evt->pszNickT = mir_tstrdup(TranslateT("Me")); + evt->pszNickT = TranslateT("Me"); evt->pszTextT = mir_tstrdup(TranslateT("O Lord, bless this Thy hand grenade that with it Thou mayest blow Thine enemies")); evt = GetTestEvent(IEEDF_SENT); - evt->pszNickT = mir_tstrdup(TranslateT("Me")); evt->pszTextT = mir_tstrdup(TranslateT("to tiny bits, in Thy mercy")); prevEvent->next = evt; prevEvent = evt; evt = GetTestEvent(0); - evt->pszNickT = mir_tstrdup(TranslateT("My contact")); + evt->pszNickT = TranslateT("My contact"); evt->pszTextT = mir_tstrdup(TranslateT("Lorem ipsum dolor sit amet,")); prevEvent->next = evt; prevEvent = evt; evt = GetTestEvent(0); - evt->pszNickT = mir_tstrdup(TranslateT("My contact")); evt->pszTextT = mir_tstrdup(TranslateT("consectetur adipisicing elit")); prevEvent->next = evt; prevEvent = evt; @@ -242,7 +199,6 @@ static EventData* GetTestEvents() static void freeEvent(EventData *evt) { - mir_free(evt->pszNickT); mir_free(evt->pszTextT); mir_free(evt->pszText2T); mir_free(evt); diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index 274ada90a9..e007c45e79 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -120,8 +120,8 @@ static int MessageEventAdded(WPARAM hContact, LPARAM lParam) } } if (hwnd == NULL || !IsWindowVisible(GetParent(hwnd))) { - TCHAR *contactName = (TCHAR*)pcli->pfnGetContactDisplayName(hContact, 0); TCHAR toolTip[256]; + mir_sntprintf(toolTip, TranslateT("Message from %s"), pcli->pfnGetContactDisplayName(hContact, 0)); CLISTEVENT cle = {}; cle.flags = CLEF_TCHAR; @@ -129,7 +129,6 @@ static int MessageEventAdded(WPARAM hContact, LPARAM lParam) cle.hDbEvent = hDbEvent; cle.hIcon = Skin_LoadIcon(SKINICON_EVENT_MESSAGE); cle.pszService = "SRMsg/ReadMessage"; - mir_sntprintf(toolTip, TranslateT("Message from %s"), contactName); cle.ptszTooltip = toolTip; pcli->pfnAddEvent(&cle); } @@ -207,9 +206,9 @@ static int TypingMessage(WPARAM hContact, LPARAM lParam) SendMessage(hwnd, DM_TYPING, 0, lParam); else if (lParam && (g_dat.flags2 & SMF2_SHOWTYPINGTRAY)) { TCHAR szTip[256]; - mir_sntprintf(szTip, TranslateT("%s is typing a message"), pcli->pfnGetContactDisplayName(hContact, 0)); - if ( ServiceExists(MS_CLIST_SYSTRAY_NOTIFY) && !(g_dat.flags2 & SMF2_SHOWTYPINGCLIST)) { + + if (ServiceExists(MS_CLIST_SYSTRAY_NOTIFY) && !(g_dat.flags2 & SMF2_SHOWTYPINGCLIST)) { MIRANDASYSTRAYNOTIFY tn; tn.szProto = NULL; tn.cbSize = sizeof(tn); diff --git a/plugins/Scriver/src/msgs.h b/plugins/Scriver/src/msgs.h index da1bc278ae..e4a8a19660 100644 --- a/plugins/Scriver/src/msgs.h +++ b/plugins/Scriver/src/msgs.h @@ -224,7 +224,6 @@ int DbEventIsMessageOrCustom(DBEVENTINFO *dbei); void StreamInEvents(HWND hwndDlg, MEVENT hDbEventFirst, int count, int fAppend); void LoadMsgLogIcons(void); void FreeMsgLogIcons(void); -TCHAR *GetNickname(MCONTACT hContact, const char *szProto); int IsAutoPopup(MCONTACT hContact); #define MSGFONTID_MYMSG 0 diff --git a/plugins/Scriver/src/msgwindow.cpp b/plugins/Scriver/src/msgwindow.cpp index 37cf89bcee..e58601d3f4 100644 --- a/plugins/Scriver/src/msgwindow.cpp +++ b/plugins/Scriver/src/msgwindow.cpp @@ -33,84 +33,49 @@ static void DrawTab(ParentWindowData *dat, HWND hwnd, WPARAM wParam, LPARAM lPar ///////////////////////////////////////////////////////////////////////////////////////// -extern TCHAR *GetNickname(MCONTACT hContact, const char* szProto); - -static const TCHAR *titleTokenNames[] = {_T("%name%"), _T("%status%"), _T("%statusmsg%"), _T("%account%")}; +static const TCHAR *titleTokenNames[] = { _T("%name%"), _T("%status%"), _T("%statusmsg%"), _T("%account%") }; TCHAR* GetWindowTitle(MCONTACT hContact, const char *szProto) { - TCHAR* tokens[4] = { 0 }; - size_t tokenLen[4] = { 0 }; - TCHAR *p, *tmplt; - TCHAR *pszNewTitleEnd = mir_tstrdup(TranslateT("Message session")); - int isTemplate = 0; + ptrT tmplt; + const TCHAR* tokens[4] = { 0 }; + + CMString tszTemplate, tszStatus, tszTitle; if (hContact && szProto) { - tokens[0] = GetNickname(hContact, szProto); - tokenLen[0] = mir_tstrlen(tokens[0]); - tokens[1] = mir_tstrdup(pcli->pfnGetStatusModeDescription(db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE), 0)); - tokenLen[1] = mir_tstrlen(tokens[1]); - tokens[2] = db_get_tsa(hContact, "CList", "StatusMsg"); - if (tokens[2] != NULL) { - tokenLen[2] = mir_tstrlen(tokens[2]); - size_t j = 0; - for (size_t i = 0; i < tokenLen[2]; i++) { - if (tokens[2][i] == '\r') - continue; - if (tokens[2][i] == '\n') - tokens[2][j++] = ' '; - else - tokens[2][j++] = tokens[2][i]; - } - tokens[2][j] = '\0'; - tokenLen[2] = j; - } + tokens[0] = pcli->pfnGetContactDisplayName(hContact, 0); + tokens[1] = pcli->pfnGetStatusModeDescription(db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE), 0); + + tszStatus = ptrT(db_get_tsa(hContact, "CList", "StatusMsg")); + tszStatus.Replace(_T("\r\n"), _T(" ")); + tokens[2] = tszStatus; char *accModule = Proto_GetBaseAccountName(hContact); if (accModule != NULL) { PROTOACCOUNT* proto = Proto_GetAccount(accModule); - if (proto != NULL) { + if (proto != NULL) tokens[3] = mir_tstrdup(proto->tszAccountName); - tokenLen[3] = mir_tstrlen(tokens[3]); - } } + tmplt = db_get_tsa(NULL, SRMMMOD, SRMSGSET_WINDOWTITLE); if (tmplt != NULL) - isTemplate = 1; + tszTemplate = tmplt; else { if (g_dat.flags & SMF_STATUSICON) - tmplt = _T("%name% - "); + tszTemplate = _T("%name% - "); else - tmplt = _T("%name% (%status%) : "); + tszTemplate = _T("%name% (%status%) : "); } } - else tmplt = _T(""); - size_t i, len; - for (len = 0, p = tmplt; *p; p++, len++) { - if (*p == '%') { - for (i = 0; i < _countof(titleTokenNames); i++) { - int tnlen = (int)mir_tstrlen(titleTokenNames[i]); - if (!_tcsncmp(p, titleTokenNames[i], tnlen)) { - len += tokenLen[i] - 1; - p += tnlen - 1; - break; - } - } - } - } - if (!isTemplate) - len += mir_tstrlen(pszNewTitleEnd); - - TCHAR *title = (TCHAR*)mir_alloc(sizeof(TCHAR) * (len + 1)); - for (len = 0, p = tmplt; *p; p++) { + for (const TCHAR *p = tszTemplate; *p; p++) { if (*p == '%') { + int i; for (i = 0; i < _countof(titleTokenNames); i++) { size_t tnlen = mir_tstrlen(titleTokenNames[i]); if (!_tcsncmp(p, titleTokenNames[i], tnlen)) { - if (tokens[i] != NULL) { - memcpy(title + len, tokens[i], sizeof(TCHAR) * tokenLen[i]); - len += tokenLen[i]; - } + if (tokens[i] != NULL) + tszTitle.Append(tokens[i]); + p += tnlen - 1; break; } @@ -118,29 +83,13 @@ TCHAR* GetWindowTitle(MCONTACT hContact, const char *szProto) if (i < _countof(titleTokenNames)) continue; } - title[len++] = *p; + tszTitle.AppendChar(*p); } - if (!isTemplate) { - memcpy(title + len, pszNewTitleEnd, sizeof(TCHAR) * mir_tstrlen(pszNewTitleEnd)); - len += mir_tstrlen(pszNewTitleEnd); - } - title[len] = '\0'; - if (isTemplate) - mir_free(tmplt); - - for (i = 0; i < _countof(titleTokenNames); i++) - mir_free(tokens[i]); + + if (tmplt == NULL) + tszTitle.Append(TranslateT("Message session")); - mir_free(pszNewTitleEnd); - return title; -} - -TCHAR* GetTabName(MCONTACT hContact) -{ - if (hContact) - return GetNickname(hContact, NULL); - - return NULL; + return tszTitle.Detach(); } static int GetChildCount(ParentWindowData *dat) @@ -191,7 +140,7 @@ static int GetTabFromHWND(ParentWindowData *dat, HWND child) return -1; } -static MessageWindowTabData * GetChildFromTab(HWND hwndTabs, int tabId) +static MessageWindowTabData* GetChildFromTab(HWND hwndTabs, int tabId) { TCITEM tci = { 0 }; tci.mask = TCIF_PARAM; @@ -201,7 +150,7 @@ static MessageWindowTabData * GetChildFromTab(HWND hwndTabs, int tabId) return NULL; } -static MessageWindowTabData * GetChildFromHWND(ParentWindowData *dat, HWND hwnd) +static MessageWindowTabData* GetChildFromHWND(ParentWindowData *dat, HWND hwnd) { int l = TabCtrl_GetItemCount(dat->hwndTabs); for (int i = 0; i < l; i++) { @@ -1337,7 +1286,6 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR SendMessage(mwtd->hwnd, DM_SWITCHINFOBAR, 0, 0); } SendMessage(hwndDlg, WM_SIZE, 0, 0); - break; case DM_SWITCHSTATUSBAR: @@ -1357,7 +1305,7 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR SendMessage(hwndDlg, WM_SIZE, 0, 0); break; - case DM_SWITCHTITLEBAR: { + case DM_SWITCHTITLEBAR: dat->flags2 ^= SMF2_SHOWTITLEBAR; ws = GetWindowLongPtr(hwndDlg, GWL_STYLE) & ~(WS_CAPTION); if (dat->flags2 & SMF2_SHOWTITLEBAR) @@ -1369,7 +1317,6 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR SetWindowPos(hwndDlg, 0, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOSENDCHANGING); RedrawWindow(hwndDlg, NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN); - } break; case DM_CASCADENEWWINDOW: @@ -1536,7 +1483,7 @@ int ScriverRestoreWindowPosition(HWND hwnd, MCONTACT hContact, const char *szMod GetMonitorInfo(hMonitor, &mi); RECT rcDesktop = mi.rcWork; if (wp.rcNormalPosition.left > rcDesktop.right || wp.rcNormalPosition.top > rcDesktop.bottom || - wp.rcNormalPosition.right < rcDesktop.left || wp.rcNormalPosition.bottom < rcDesktop.top) return 1; + wp.rcNormalPosition.right < rcDesktop.left || wp.rcNormalPosition.bottom < rcDesktop.top) return 1; SetWindowPlacement(hwnd, &wp); return 0; } diff --git a/plugins/Scriver/src/msgwindow.h b/plugins/Scriver/src/msgwindow.h index c5ec63c224..d3e8092b8b 100644 --- a/plugins/Scriver/src/msgwindow.h +++ b/plugins/Scriver/src/msgwindow.h @@ -87,7 +87,6 @@ struct TabControlData }; TCHAR* GetWindowTitle(MCONTACT hContact, const char *szProto); -TCHAR* GetTabName(MCONTACT hContact); HWND GetParentWindow(MCONTACT hContact, BOOL bChat); void NotifyLocalWinEvent(MCONTACT hContact, HWND hwnd, unsigned int type); diff --git a/plugins/Scriver/src/sendqueue.cpp b/plugins/Scriver/src/sendqueue.cpp index d96cb670e3..1b2b358bdb 100644 --- a/plugins/Scriver/src/sendqueue.cpp +++ b/plugins/Scriver/src/sendqueue.cpp @@ -104,7 +104,7 @@ void ReportSendQueueTimeouts(HWND hwndSender) if (item->hwndSender == hwndSender && item->hwndErrorDlg == NULL) { if (hwndSender != NULL) { ErrorWindowData *ewd = (ErrorWindowData *)mir_alloc(sizeof(ErrorWindowData)); - ewd->szName = GetNickname(item->hContact, item->proto); + ewd->szName = mir_tstrdup(pcli->pfnGetContactDisplayName(item->hContact, 0)); ewd->szDescription = mir_tstrdup(TranslateT("The message send timed out.")); ewd->szText = GetSendBufferMsg(item); ewd->hwndParent = hwndSender; diff --git a/plugins/Scriver/src/utils.cpp b/plugins/Scriver/src/utils.cpp index 95a4bc074c..588871c788 100644 --- a/plugins/Scriver/src/utils.cpp +++ b/plugins/Scriver/src/utils.cpp @@ -27,37 +27,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define TTI_NONE 0 #endif -wchar_t* a2w(const char *src, int len) -{ - wchar_t *wline; - int i; - if (len < 0) { - len = (int)mir_strlen(src); - } - wline = (wchar_t*)mir_alloc(2 * (len + 1)); - for (i = 0; i < len; i++) { - wline[i] = src[i]; - } - wline[i] = 0; - return wline; -} - -static int mimFlags = 0; - -enum MIMFLAGS -{ - MIM_CHECKED = 1, - MIM_UNICODE = 2 -}; - -int IsUnicodeMIM() -{ - if (!(mimFlags & MIM_CHECKED)) - mimFlags = MIM_CHECKED | MIM_UNICODE; - - return TRUE; -} - const char *filename = "scriver.log"; void logInfo(const char *fmt, ...) diff --git a/plugins/Scriver/src/utils.h b/plugins/Scriver/src/utils.h index 07847abb8d..89ee584390 100644 --- a/plugins/Scriver/src/utils.h +++ b/plugins/Scriver/src/utils.h @@ -34,7 +34,6 @@ enum SEARCHENGINES { SEARCHENGINE_FOODNETWORK = 8 }; -int IsUnicodeMIM(); TCHAR *limitText(TCHAR *text, int limit); void logInfo(const char *fmt, ...); int GetRichTextLength(HWND hwnd, int codepage, BOOL inBytes); -- cgit v1.2.3