diff options
author | Tobias Weimer <wishmaster51@googlemail.com> | 2014-08-10 11:19:17 +0000 |
---|---|---|
committer | Tobias Weimer <wishmaster51@googlemail.com> | 2014-08-10 11:19:17 +0000 |
commit | 5867abd3dae59bcb8ea93d77ee3ad9e203ecff79 (patch) | |
tree | 6ee7aadd4befb753e407abd6dbd03c55a5588ef5 /src | |
parent | 9319159d78d3f42cc3affc624ee088b47eec47ff (diff) |
Status changes are now shown in font for "Other events" (fixes #553)
git-svn-id: http://svn.miranda-ng.org/main/trunk@10142 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/core/stdmsg/src/msgdialog.cpp | 74 | ||||
-rw-r--r-- | src/core/stdmsg/src/msglog.cpp | 26 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgoptions.cpp | 4 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgs.cpp | 32 | ||||
-rw-r--r-- | src/core/stdmsg/src/statusicon.cpp | 8 |
5 files changed, 66 insertions, 78 deletions
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index 073839130d..f0649c253e 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -43,19 +43,18 @@ static const UINT sendControls[] = { IDC_MESSAGE }; static void NotifyLocalWinEvent(MCONTACT hContact, HWND hwnd, unsigned int type)
{
- if (hContact == NULL || hwnd == NULL)
- return;
-
- MessageWindowEventData mwe = { 0 };
- mwe.cbSize = sizeof(mwe);
- mwe.hContact = hContact;
- mwe.hwndWindow = hwnd;
- mwe.szModule = SRMMMOD;
- mwe.uType = type;
- mwe.uFlags = MSG_WINDOW_UFLAG_MSG_BOTH;
- mwe.hwndInput = GetDlgItem(hwnd, IDC_MESSAGE);
- mwe.hwndLog = GetDlgItem(hwnd, IDC_LOG);
- NotifyEventHooks(hHookWinEvt, 0, (LPARAM)&mwe);
+ if (hContact != NULL && hwnd != NULL) {
+ MessageWindowEventData mwe = { 0 };
+ mwe.cbSize = sizeof(mwe);
+ mwe.hContact = hContact;
+ mwe.hwndWindow = hwnd;
+ mwe.szModule = SRMMMOD;
+ mwe.uType = type;
+ mwe.uFlags = MSG_WINDOW_UFLAG_MSG_BOTH;
+ mwe.hwndInput = GetDlgItem(hwnd, IDC_MESSAGE);
+ mwe.hwndLog = GetDlgItem(hwnd, IDC_LOG);
+ NotifyEventHooks(hHookWinEvt, 0, (LPARAM)&mwe);
+ }
}
static BOOL IsUtfSendAvailable(MCONTACT hContact)
@@ -149,10 +148,10 @@ static void AddToFileList(TCHAR ***pppFiles, int *totalCount, const TCHAR* szFil if (GetFileAttributes(szFilename) & FILE_ATTRIBUTE_DIRECTORY) {
WIN32_FIND_DATA fd;
- HANDLE hFind;
TCHAR szPath[MAX_PATH];
mir_sntprintf(szPath, SIZEOF(szPath), _T("%s\\*"), szFilename);
- if ((hFind = FindFirstFile(szPath, &fd)) != INVALID_HANDLE_VALUE) {
+ HANDLE hFind = FindFirstFile(szPath, &fd);
+ if (hFind != INVALID_HANDLE_VALUE) {
do {
if (!_tcscmp(fd.cFileName, _T(".")) || !_tcscmp(fd.cFileName, _T(".."))) continue;
mir_sntprintf(szPath, SIZEOF(szPath), _T("%s\\%s"), szFilename, fd.cFileName);
@@ -199,12 +198,12 @@ static void ShowTime(SrmmWindowData *dat) static void SetupStatusBar(HWND hwndDlg, SrmmWindowData *dat)
{
- int icons_width, cx, i = 0, statwidths[4];
- RECT rc;
+ int i = 0, statwidths[4];
+ int icons_width = GetStatusIconsCount(dat->hContact) * (GetSystemMetrics(SM_CXSMICON) + 2) + SB_GRIP_WIDTH;
- icons_width = GetStatusIconsCount(dat->hContact) * (GetSystemMetrics(SM_CXSMICON) + 2) + SB_GRIP_WIDTH;
+ RECT rc;
GetWindowRect(dat->hwndStatus, &rc);
- cx = rc.right - rc.left;
+ int cx = rc.right - rc.left;
if (dat->hTimeZone) {
if (g_dat.flags & SMF_SHOWREADCHAR)
@@ -225,9 +224,7 @@ static void SetupStatusBar(HWND hwndDlg, SrmmWindowData *dat) static void SetDialogToType(HWND hwndDlg)
{
- SrmmWindowData *dat;
-
- dat = (SrmmWindowData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ SrmmWindowData *dat = (SrmmWindowData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
if (dat->hContact)
ShowMultipleControls(hwndDlg, infoLineControls, SIZEOF(infoLineControls), (g_dat.flags&SMF_SHOWINFO) ? SW_SHOW : SW_HIDE);
else
@@ -378,8 +375,6 @@ static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd, UINT msg, WPARAM wPar case WM_CONTEXTMENU:
{
- HMENU hMenu;
- CHARRANGE sel;
static const CHARRANGE all = { 0, -1 };
MessageWindowPopupData mwpd = { 0 };
@@ -389,11 +384,12 @@ static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd, UINT msg, WPARAM wPar mwpd.hContact = pdat->hContact;
mwpd.hwnd = hwnd;
- hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_CONTEXT));
+ HMENU hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_CONTEXT));
mwpd.hMenu = GetSubMenu(hMenu, 2);
TranslateMenu(mwpd.hMenu);
+ CHARRANGE sel;
SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM)&sel);
if (sel.cpMin == sel.cpMax) {
EnableMenuItem(mwpd.hMenu, IDM_CUT, MF_BYCOMMAND | MF_GRAYED);
@@ -1099,26 +1095,22 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP case DM_UPDATETITLE:
{
- TCHAR newtitle[256], oldtitle[256], *szStatus;
- TCHAR *contactName, *pszNewTitleEnd;
- DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)wParam;
-
- pszNewTitleEnd = _T("Message Session");
+ TCHAR newtitle[256];
if (dat->hContact) {
if (dat->szProto) {
- TCHAR buf[128] = _T("");
int statusIcon = db_get_b(NULL, SRMMMOD, SRMSGSET_STATUSICON, SRMSGDEFSET_STATUSICON);
dat->wStatus = db_get_w(dat->hContact, dat->szProto, "Status", ID_STATUS_OFFLINE);
- contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0);
+ TCHAR *contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0);
+ TCHAR buf[128] = _T("");
if (strcmp(dat->szProto, META_PROTO)) {
CONTACTINFO ci = { 0 };
ci.cbSize = sizeof(ci);
ci.hContact = dat->hContact;
ci.szProto = dat->szProto;
ci.dwFlag = CNF_DISPLAYUID | CNF_TCHAR;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)& ci)) {
+ if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
switch (ci.type) {
case CNFT_ASCIIZ:
mir_sntprintf(buf, SIZEOF(buf), _T("%s"), (TCHAR*)ci.pszVal);
@@ -1135,12 +1127,13 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP else
SetDlgItemText(hwndDlg, IDC_NAME, contactName);
- szStatus = pcli->pfnGetStatusModeDescription(dat->szProto == NULL ? ID_STATUS_OFFLINE : db_get_w(dat->hContact, dat->szProto, "Status", ID_STATUS_OFFLINE), 0);
+ TCHAR *szStatus = pcli->pfnGetStatusModeDescription(dat->szProto == NULL ? ID_STATUS_OFFLINE : db_get_w(dat->hContact, dat->szProto, "Status", ID_STATUS_OFFLINE), 0);
if (statusIcon)
- mir_sntprintf(newtitle, SIZEOF(newtitle), _T("%s - %s"), contactName, TranslateTS(pszNewTitleEnd));
+ mir_sntprintf(newtitle, SIZEOF(newtitle), _T("%s - %s"), contactName, TranslateT("Message Session"));
else
- mir_sntprintf(newtitle, SIZEOF(newtitle), _T("%s (%s): %s"), contactName, szStatus, TranslateTS(pszNewTitleEnd));
-
+ mir_sntprintf(newtitle, SIZEOF(newtitle), _T("%s (%s): %s"), contactName, szStatus, TranslateT("Message Session"));
+
+ DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)wParam;
if (!cws || (!strcmp(cws->szModule, dat->szProto) && !strcmp(cws->szSetting, "Status"))) {
InvalidateRect(GetDlgItem(hwndDlg, IDC_PROTOCOL), NULL, TRUE);
if (statusIcon)
@@ -1150,8 +1143,10 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP dat->wOldStatus = dat->wStatus;
}
}
- else lstrcpyn(newtitle, pszNewTitleEnd, SIZEOF(newtitle));
+ else
+ lstrcpyn(newtitle, TranslateT("Message Session"), SIZEOF(newtitle));
+ TCHAR oldtitle[256];
GetWindowText(hwndDlg, oldtitle, SIZEOF(oldtitle));
if (_tcscmp(newtitle, oldtitle)) { //swt() flickers even if the title hasn't actually changed
SetWindowText(hwndDlg, newtitle);
@@ -1682,9 +1677,8 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP case IDM_COPYLINK:
if (OpenClipboard(hwndDlg)) {
- HGLOBAL hData;
EmptyClipboard();
- hData = GlobalAlloc(GMEM_MOVEABLE, (_tcslen(tr.lpstrText) + 1) * sizeof(TCHAR));
+ HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE, (_tcslen(tr.lpstrText) + 1) * sizeof(TCHAR));
_tcscpy((TCHAR*)GlobalLock(hData), tr.lpstrText);
GlobalUnlock(hData);
SetClipboardData(CF_UNICODETEXT, hData);
diff --git a/src/core/stdmsg/src/msglog.cpp b/src/core/stdmsg/src/msglog.cpp index 558a61ed54..8bcdfddd95 100644 --- a/src/core/stdmsg/src/msglog.cpp +++ b/src/core/stdmsg/src/msglog.cpp @@ -232,7 +232,6 @@ int DbEventIsShown(DBEVENTINFO *dbei) //mir_free() the return value
static char *CreateRTFFromDbEvent(SrmmWindowData *dat, MCONTACT hContact, HANDLE hDbEvent, struct LogStreamData *streamData)
{
- char *buffer;
int bufferAlloced, bufferEnd;
int showColon = 0;
@@ -256,7 +255,7 @@ static char *CreateRTFFromDbEvent(SrmmWindowData *dat, MCONTACT hContact, HANDLE }
bufferEnd = 0;
bufferAlloced = 1024;
- buffer = (char *)mir_alloc(bufferAlloced);
+ char *buffer = (char *)mir_alloc(bufferAlloced);
buffer[0] = '\0';
if (!dat->bIsAutoRTL && !streamData->isEmpty)
@@ -329,16 +328,8 @@ static char *CreateRTFFromDbEvent(SrmmWindowData *dat, MCONTACT hContact, HANDLE if (showColon)
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "%s :", SetToStyle(dbei.flags & DBEF_SENT ? MSGFONTID_MYCOLON : MSGFONTID_YOURCOLON));
- switch (dbei.eventType) {
TCHAR *msg, *szName;
- default:
- case EVENTTYPE_MESSAGE:
- msg = DbGetEventTextT(&dbei, CP_ACP);
- AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, " %s ", SetToStyle(dbei.flags & DBEF_SENT ? MSGFONTID_MYMSG : MSGFONTID_YOURMSG));
- AppendToBufferWithRTF(&buffer, &bufferEnd, &bufferAlloced, msg);
- mir_free(msg);
- break;
-
+ switch (dbei.eventType) {
case EVENTTYPE_JABBER_CHATSTATES:
case EVENTTYPE_JABBER_PRESENCE:
if (dbei.flags & DBEF_SENT) {
@@ -368,14 +359,13 @@ static char *CreateRTFFromDbEvent(SrmmWindowData *dat, MCONTACT hContact, HANDLE }
break;
- case EVENTTYPE_FILE:
+ case EVENTTYPE_FILE: {
char* filename = (char*)dbei.pBlob + sizeof(DWORD);
char* descr = filename + strlen(filename) + 1;
TCHAR* ptszFileName = DbGetEventStringT(&dbei, filename);
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, " %s ", SetToStyle(MSGFONTID_NOTICE));
- AppendToBufferWithRTF(&buffer, &bufferEnd, &bufferAlloced,
- (dbei.flags & DBEF_SENT) ? TranslateT("File sent") : TranslateT("File received"));
+ AppendToBufferWithRTF(&buffer, &bufferEnd, &bufferAlloced, (dbei.flags & DBEF_SENT) ? TranslateT("File sent") : TranslateT("File received"));
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, ": ");
AppendToBufferWithRTF(&buffer, &bufferEnd, &bufferAlloced, ptszFileName);
mir_free(ptszFileName);
@@ -389,6 +379,14 @@ static char *CreateRTFFromDbEvent(SrmmWindowData *dat, MCONTACT hContact, HANDLE }
break;
}
+ case EVENTTYPE_MESSAGE:
+ default:
+ msg = DbGetEventTextT(&dbei, CP_ACP);
+ AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, " %s ", SetToStyle((dbei.eventType == EVENTTYPE_MESSAGE) ? ((dbei.flags & DBEF_SENT) ? MSGFONTID_MYMSG : MSGFONTID_YOURMSG) : MSGFONTID_NOTICE));
+ AppendToBufferWithRTF(&buffer, &bufferEnd, &bufferAlloced, msg);
+ mir_free(msg);
+
+ }
if (dat->bIsAutoRTL)
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\par");
diff --git a/src/core/stdmsg/src/msgoptions.cpp b/src/core/stdmsg/src/msgoptions.cpp index f40fa6e49b..909c94fc57 100644 --- a/src/core/stdmsg/src/msgoptions.cpp +++ b/src/core/stdmsg/src/msgoptions.cpp @@ -43,7 +43,7 @@ static const fontOptionsList[] = { LPGENT("Incoming time"), RGB(0, 0, 0), _T("Terminal"), DBFONTF_BOLD, -9},
{ LPGENT("Incoming colon"), RGB(215, 0, 0), _T("Arial"), 0, -11},
{ LPGENT("Message area"), RGB(0, 0, 0), _T("Arial"), 0, -12},
- { LPGENT("Notices"), RGB(90, 90, 160), _T("Arial"), 0, -12},
+ { LPGENT("Other events"), RGB(90, 90, 160), _T("Arial"), 0, -12},
};
static BYTE MsgDlgGetFontDefaultCharset(const TCHAR* szFont)
@@ -553,7 +553,7 @@ static INT_PTR CALLBACK DlgProcTypeOptions(HWND hwndDlg, UINT msg, WPARAM wParam return FALSE;
}
-static int OptInitialise(WPARAM wParam, LPARAM lParam)
+static int OptInitialise(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { sizeof(odp) };
odp.position = 910000000;
diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index 0223d8be8e..ac00e00bac 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -87,21 +87,20 @@ static int MessageEventAdded(WPARAM hContact, LPARAM lParam) return 0;
}
- TCHAR toolTip[256], *contactName;
CLISTEVENT cle = { sizeof(cle) };
cle.hContact = hContact;
cle.hDbEvent = (HANDLE)lParam;
cle.flags = CLEF_TCHAR;
cle.hIcon = LoadSkinnedIcon(SKINICON_EVENT_MESSAGE);
cle.pszService = "SRMsg/ReadMessage";
- contactName = pcli->pfnGetContactDisplayName(hContact, 0);
- mir_sntprintf(toolTip, SIZEOF(toolTip), TranslateT("Message from %s"), contactName);
+ TCHAR toolTip[256];
+ mir_sntprintf(toolTip, SIZEOF(toolTip), TranslateT("Message from %s"), pcli->pfnGetContactDisplayName(hContact, 0));
cle.ptszTooltip = toolTip;
CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle);
return 0;
}
-INT_PTR SendMessageCmd(MCONTACT hContact, char* msg, int isWchar)
+INT_PTR SendMessageCmd(MCONTACT hContact, char *msg, int isWchar)
{
/* does the MCONTACT's protocol support IM messages? */
char *szProto = GetContactProto(hContact);
@@ -110,16 +109,14 @@ INT_PTR SendMessageCmd(MCONTACT hContact, char* msg, int isWchar) hContact = db_mc_tryMeta(hContact);
- HWND hwnd;
- if (hwnd = WindowList_Find(g_dat.hMessageWindowList, hContact)) {
+ HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, hContact);
+ if (hwnd) {
if (msg) {
- HWND hEdit;
- hEdit = GetDlgItem(hwnd, IDC_MESSAGE);
- SendMessage(hEdit, EM_SETSEL, -1, SendMessage(hEdit, WM_GETTEXTLENGTH, 0, 0));
+ SendDlgItemMessage(hwnd, IDC_MESSAGE, EM_SETSEL, -1, SendDlgItemMessage(hwnd, IDC_MESSAGE, WM_GETTEXTLENGTH, 0, 0));
if (isWchar)
- SendMessageW(hEdit, EM_REPLACESEL, FALSE, (LPARAM)msg);
+ SendDlgItemMessageW(hwnd, IDC_MESSAGE, EM_REPLACESEL, FALSE, (LPARAM)msg);
else
- SendMessageA(hEdit, EM_REPLACESEL, FALSE, (LPARAM)msg);
+ SendDlgItemMessageA(hwnd, IDC_MESSAGE, EM_REPLACESEL, FALSE, (LPARAM)msg);
}
ShowWindow(hwnd, SW_RESTORE);
SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
@@ -215,10 +212,11 @@ static int MessageSettingChanged(WPARAM hContact, LPARAM lParam) return 0;
}
-static int ContactDeleted(WPARAM wParam, LPARAM lParam)
+// If a contact gets deleted, close its message window if there is any
+static int ContactDeleted(WPARAM wParam, LPARAM)
{
- HWND hwnd;
- if (hwnd = WindowList_Find(g_dat.hMessageWindowList, wParam))
+ HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, wParam);
+ if (hwnd)
SendMessage(hwnd, WM_CLOSE, 0, 0);
return 0;
@@ -260,7 +258,7 @@ static void RestoreUnreadMessageAlerts(void) cle.hContact = hContact;
cle.hDbEvent = hDbEvent;
mir_sntprintf(toolTip, SIZEOF(toolTip), TranslateT("Message from %s"), pcli->pfnGetContactDisplayName(hContact, 0));
- CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)& cle);
+ CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle);
}
}
}
@@ -269,7 +267,7 @@ static void RestoreUnreadMessageAlerts(void) void RegisterSRMMFonts(void);
-static int FontsChanged(WPARAM wParam, LPARAM lParam)
+static int FontsChanged(WPARAM, LPARAM)
{
WindowList_Broadcast(g_dat.hMessageWindowList, DM_OPTIONSAPPLIED, 0, 0);
return 0;
@@ -329,7 +327,7 @@ static int PrebuildContactMenu(WPARAM hContact, LPARAM lParam) return 0;
}
-static INT_PTR GetWindowAPI(WPARAM wParam, LPARAM lParam)
+static INT_PTR GetWindowAPI(WPARAM, LPARAM)
{
return PLUGIN_MAKE_VERSION(0, 0, 0, 4);
}
diff --git a/src/core/stdmsg/src/statusicon.cpp b/src/core/stdmsg/src/statusicon.cpp index 24b09d1a6d..4d2b0c8bf7 100644 --- a/src/core/stdmsg/src/statusicon.cpp +++ b/src/core/stdmsg/src/statusicon.cpp @@ -38,14 +38,12 @@ static int OnSrmmIconChanged(WPARAM hContact, LPARAM) void DrawStatusIcons(MCONTACT hContact, HDC hDC, RECT r, int gap)
{
- HICON hIcon;
int x = r.left;
int nIcon = 0;
- StatusIconData *sid;
- while ((sid = Srmm_GetNthIcon(hContact, nIcon++)) != 0 && x < r.right) {
- if ((sid->flags & MBF_DISABLED) && sid->hIconDisabled) hIcon = sid->hIconDisabled;
- else hIcon = sid->hIcon;
+ StatusIconData *sid = Srmm_GetNthIcon(hContact, nIcon++);
+ while (sid != 0 && x < r.right) {
+ HICON hIcon = ((sid->flags & MBF_DISABLED) && sid->hIconDisabled) ? sid->hIconDisabled : sid->hIcon;
SetBkMode(hDC, TRANSPARENT);
DrawIconEx(hDC, x, (r.top + r.bottom - GetSystemMetrics(SM_CYSMICON)) >> 1, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL);
|