summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-08-27 19:50:58 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-08-27 19:50:58 +0000
commit1e737f420221294c6b35bb3ef10a4e1fdf982a9f (patch)
treee41f7a7ecb51bf920fdd37623983bd4de2343795 /plugins
parentfb8e144f96d9febcb16f1b18f4d87fe9fcec3c10 (diff)
fix for displaying account names in Chat's popus
git-svn-id: http://svn.miranda-ng.org/main/trunk@5866 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Scriver/src/chat/manager.cpp5
-rw-r--r--plugins/Scriver/src/chat/tools.cpp51
-rw-r--r--plugins/TabSRMM/src/chat/manager.cpp2
-rw-r--r--plugins/TabSRMM/src/chat/tools.cpp51
4 files changed, 49 insertions, 60 deletions
diff --git a/plugins/Scriver/src/chat/manager.cpp b/plugins/Scriver/src/chat/manager.cpp
index 009b9c266b..7d3191c733 100644
--- a/plugins/Scriver/src/chat/manager.cpp
+++ b/plugins/Scriver/src/chat/manager.cpp
@@ -1104,11 +1104,10 @@ USERINFO * UM_SortUser(USERINFO** ppUserList, const TCHAR* pszUID)
USERINFO* UM_AddUser(STATUSINFO* pStatusList, USERINFO** ppUserList, const TCHAR* pszUID, const TCHAR* pszNick, WORD wStatus)
{
- USERINFO * pTemp = *ppUserList, *pLast = NULL;
-
- if (!pStatusList || !ppUserList || !ppUserList)
+ if (!pStatusList || !ppUserList)
return NULL;
+ USERINFO * pTemp = *ppUserList, *pLast = NULL;
while(pTemp && UM_CompareItem(pTemp, pszNick, wStatus) <= 0)
{
pLast = pTemp;
diff --git a/plugins/Scriver/src/chat/tools.cpp b/plugins/Scriver/src/chat/tools.cpp
index a3ab13a391..ae6439183e 100644
--- a/plugins/Scriver/src/chat/tools.cpp
+++ b/plugins/Scriver/src/chat/tools.cpp
@@ -77,12 +77,12 @@ static void __stdcall ShowRoomFromPopup(void * pi)
ShowRoom(si, WINDOW_VISIBLE, TRUE);
}
-static INT_PTR CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message) {
case WM_COMMAND:
if (HIWORD(wParam) == STN_CLICKED) {
- SESSION_INFO *si = (SESSION_INFO*)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd,0);;
+ SESSION_INFO *si = (SESSION_INFO*) PUGetPluginData(hWnd);
CallFunctionAsync(ShowRoomFromPopup, si);
@@ -92,7 +92,7 @@ static INT_PTR CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPA
break;
case WM_CONTEXTMENU:
{
- SESSION_INFO *si = (SESSION_INFO*)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd,0);
+ SESSION_INFO *si = (SESSION_INFO*) PUGetPluginData(hWnd);
if (si->windowData.hContact)
if (CallService(MS_CLIST_GETEVENT, (WPARAM)si->windowData.hContact, 0))
CallService(MS_CLIST_REMOVEEVENT, (WPARAM)si->windowData.hContact, (LPARAM)"chaticon");
@@ -124,9 +124,12 @@ static int ShowPopup (HANDLE hContact, SESSION_INFO *si, HICON hIcon, char* pszP
else
pd.lchIcon = GetCachedIcon("chat_window");
- mir_sntprintf(pd.lptzContactName, MAX_CONTACTNAME-1, _T("%S - %s"),
- pszProtoName, CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR ));
- lstrcpyn( pd.lptzText, TranslateTS(szBuf), MAX_SECONDLINE-1);
+ PROTOACCOUNT *pa = ProtoGetAccount(pszProtoName);
+ mir_sntprintf(pd.lptzContactName, MAX_CONTACTNAME-1, _T("%s - %s"),
+ (pa == NULL) ? _A2T(pszProtoName) : pa->tszAccountName,
+ pcli->pfnGetContactDisplayName(hContact, 0));
+
+ lstrcpyn( pd.lptzText, TranslateTS(szBuf), MAX_SECONDLINE);
pd.iSeconds = g_Settings.iPopupTimeout;
if (g_Settings.iPopupStyle == 2) {
@@ -142,7 +145,7 @@ static int ShowPopup (HANDLE hContact, SESSION_INFO *si, HICON hIcon, char* pszP
pd.colorText = crBkg;
}
- pd.PluginWindowProc = (WNDPROC)PopupDlgProc;
+ pd.PluginWindowProc = PopupDlgProc;
pd.PluginData = si;
return PUAddPopupT(&pd);
}
@@ -267,16 +270,13 @@ static BOOL DoPopup(SESSION_INFO *si, GCEVENT * gce)
BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT * gce, BOOL bHighlight, int bManyFix)
{
- BOOL bInactive;
- int iEvent;
-
if (!gce || !si || gce->bIsMe || si->iType == GCW_SERVER)
return FALSE;
- bInactive = si->hWnd == NULL || GetForegroundWindow() != GetParent(si->hWnd);
+ BOOL bInactive = si->hWnd == NULL || GetForegroundWindow() != GetParent(si->hWnd);
// bInactive |= GetActiveWindow() != si->hWnd; // Removed this, because it seemed to be FALSE, even when window was focused, causing incorrect notifications
- iEvent = gce->pDest->iType;
+ int iEvent = gce->pDest->iType;
if ( bHighlight ) {
gce->pDest->iType |= GC_EVENT_HIGHLIGHT;
@@ -404,9 +404,8 @@ void CheckColorsInModule(const char* pszModule)
TCHAR* my_strstri( const TCHAR* s1, const TCHAR* s2)
{
- int i,j,k;
- for(i=0;s1[i];i++)
- for(j=i,k=0; _totlower(s1[j]) == _totlower(s2[k]);j++,k++)
+ for(int i=0;s1[i];i++)
+ for(int j=i,k=0; _totlower(s1[j]) == _totlower(s2[k]);j++,k++)
if (!s2[k+1])
return (TCHAR*)(s1+i);
@@ -493,35 +492,32 @@ BOOL IsHighlighted(SESSION_INFO *si, const TCHAR* pszText)
BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce)
{
- MODULEINFO * mi = NULL;
TCHAR szBuffer[4096];
TCHAR szLine[4096];
TCHAR szTime[100];
- FILE *hFile = NULL;
TCHAR tszFile[MAX_PATH];
TCHAR tszFolder[MAX_PATH];
TCHAR p = '\0';
- BOOL bFileJustCreated = TRUE;
if (!si || !gce)
return FALSE;
- mi = MM_FindModule(si->pszModule);
+ MODULEINFO *mi = MM_FindModule(si->pszModule);
if ( !mi )
return FALSE;
szBuffer[0] = '\0';
lstrcpyn(tszFile, GetChatLogsFilename(si->windowData.hContact, gce->time), MAX_PATH);
- bFileJustCreated = !PathFileExists(tszFile);
- _tcscpy(tszFolder, tszFile);
+ BOOL bFileJustCreated = !PathFileExists(tszFile);
+ _tcsncpy(tszFolder, tszFile, MAX_PATH);
PathRemoveFileSpec(tszFolder);
if (!PathIsDirectory(tszFolder))
CreateDirectoryTreeT(tszFolder);
lstrcpyn(szTime, MakeTimeStamp(g_Settings.pszTimeStampLog, gce->time), 99);
- hFile = _tfopen(tszFile, _T("ab+"));
+ FILE *hFile = _tfopen(tszFile, _T("ab+"));
if (hFile) {
TCHAR szTemp[512], szTemp2[512];
TCHAR* pszNick = NULL;
@@ -663,7 +659,6 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce)
UINT CreateGCMenu(HWND hwnd, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, TCHAR* pszUID, TCHAR* pszWordText)
{
GCMENUITEMS gcmi = {0};
- int i;
HMENU hSubMenu = 0;
*hMenu = GetSubMenu(g_hMenu, iIndex);
@@ -709,7 +704,7 @@ UINT CreateGCMenu(HWND hwnd, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *s
if (gcmi.nItems > 0)
AppendMenu(*hMenu, MF_SEPARATOR, 0, 0);
- for (i = 0; i < gcmi.nItems; i++) {
+ for (int i = 0; i < gcmi.nItems; i++) {
TCHAR* ptszDescr = a2tf(gcmi.Item[i].pszDesc, si->dwFlags);
TCHAR* ptszText = TranslateTS(ptszDescr);
DWORD dwState = gcmi.Item[i].bDisabled ? MF_GRAYED : 0;
@@ -755,7 +750,6 @@ void DestroyGCMenu(HMENU *hMenu, int iIndex)
BOOL DoEventHookAsync(HWND hwnd, const TCHAR* pszID, const char* pszModule, int iType, TCHAR* pszUID, TCHAR* pszText, DWORD dwItem)
{
- SESSION_INFO *si;
GCHOOK* gch = (GCHOOK*)mir_alloc( sizeof( GCHOOK ));
GCDEST* gcd = (GCDEST*)mir_alloc( sizeof( GCDEST ));
@@ -763,7 +757,8 @@ BOOL DoEventHookAsync(HWND hwnd, const TCHAR* pszID, const char* pszModule, int
memset( gcd, 0, sizeof( GCDEST ));
replaceStrA( &gcd->pszModule, pszModule);
- if (( si = SM_FindSession(pszID, pszModule)) == NULL )
+ SESSION_INFO *si = SM_FindSession(pszID, pszModule);
+ if (si == NULL)
return FALSE;
if ( !( si->dwFlags & GC_UNICODE )) {
@@ -786,12 +781,12 @@ BOOL DoEventHookAsync(HWND hwnd, const TCHAR* pszID, const char* pszModule, int
BOOL DoEventHook(const TCHAR* pszID, const char* pszModule, int iType, const TCHAR* pszUID, const TCHAR* pszText, DWORD dwItem)
{
- SESSION_INFO *si;
GCHOOK gch = {0};
GCDEST gcd = {0};
gcd.pszModule = (char*)pszModule;
- if ((si = SM_FindSession(pszID, pszModule)) == NULL)
+ SESSION_INFO *si = SM_FindSession(pszID, pszModule);
+ if (si == NULL)
return FALSE;
if ( !(si->dwFlags & GC_UNICODE)) {
diff --git a/plugins/TabSRMM/src/chat/manager.cpp b/plugins/TabSRMM/src/chat/manager.cpp
index 13215f3f92..d8b62225ac 100644
--- a/plugins/TabSRMM/src/chat/manager.cpp
+++ b/plugins/TabSRMM/src/chat/manager.cpp
@@ -1082,7 +1082,7 @@ USERINFO* UM_SortUser(USERINFO** ppUserList, const TCHAR* pszUID)
USERINFO* UM_AddUser(STATUSINFO* pStatusList, USERINFO** ppUserList, const TCHAR* pszUID, const TCHAR* pszNick, WORD wStatus)
{
- if (!pStatusList || !ppUserList || !ppUserList)
+ if (!pStatusList || !ppUserList)
return NULL;
USERINFO *pTemp = *ppUserList, *pLast = NULL;
diff --git a/plugins/TabSRMM/src/chat/tools.cpp b/plugins/TabSRMM/src/chat/tools.cpp
index 71db16c4c9..c305c27fdd 100644
--- a/plugins/TabSRMM/src/chat/tools.cpp
+++ b/plugins/TabSRMM/src/chat/tools.cpp
@@ -156,7 +156,7 @@ static void TSAPI Chat_DismissPopup(const SESSION_INFO *si, HWND hwndPopup)
PUDeletePopup(hwndPopup);
}
-static INT_PTR CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
SESSION_INFO *si = (SESSION_INFO*)PUGetPluginData(hWnd);
@@ -204,9 +204,13 @@ static int ShowPopup(HANDLE hContact, SESSION_INFO *si, HICON hIcon, char* pszP
pd.lchIcon = hIcon ;
else
pd.lchIcon = LoadIconEx(IDI_CHANMGR, "window", 0, 0);
+
+ PROTOACCOUNT *pa = ProtoGetAccount(pszProtoName);
+ mir_sntprintf(pd.lptzContactName, MAX_CONTACTNAME-1, _T("%s - %s"),
+ (pa == NULL) ? _A2T(pszProtoName) : pa->tszAccountName,
+ pcli->pfnGetContactDisplayName(hContact, 0));
- mir_sntprintf(pd.lptzContactName, MAX_CONTACTNAME - 1, _T("%S - %s"), pszProtoName, pcli->pfnGetContactDisplayName(hContact, 0));
- lstrcpyn(pd.lptzText, TranslateTS(szBuf), MAX_SECONDLINE - 1);
+ lstrcpyn(pd.lptzText, TranslateTS(szBuf), MAX_SECONDLINE);
pd.iSeconds = g_Settings.iPopupTimeout;
if (g_Settings.iPopupStyle == 2) {
@@ -220,7 +224,7 @@ static int ShowPopup(HANDLE hContact, SESSION_INFO *si, HICON hIcon, char* pszP
pd.colorText = crBkg;
}
- pd.PluginWindowProc = (WNDPROC)PopupDlgProc;
+ pd.PluginWindowProc = PopupDlgProc;
pd.PluginData = si;
return PUAddPopupT(&pd);
}
@@ -736,11 +740,7 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce)
{
TCHAR szBuffer[4096];
TCHAR szLine[4096];
- TCHAR szTime[100];
- FILE *hFile = NULL;
- TCHAR tszFolder[MAX_PATH];
TCHAR p = '\0';
- BOOL bFileJustCreated = TRUE;
if (!si || !gce)
return FALSE;
@@ -758,15 +758,18 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce)
szBuffer[0] = '\0';
GetChatLogsFilename(si, gce->time);
- bFileJustCreated = !PathFileExists(si->pszLogFileName);
+ BOOL bFileJustCreated = !PathFileExists(si->pszLogFileName);
+
+ TCHAR tszFolder[MAX_PATH];
_tcscpy(tszFolder, si->pszLogFileName);
PathRemoveFileSpec(tszFolder);
if (!PathIsDirectory(tszFolder))
CreateDirectoryTreeT(tszFolder);
+ TCHAR szTime[100];
lstrcpyn(szTime, MakeTimeStamp(g_Settings.pszTimeStampLog, gce->time), 99);
- hFile = _tfopen(si->pszLogFileName, _T("ab+"));
+ FILE *hFile = _tfopen(si->pszLogFileName, _T("ab+"));
if (hFile) {
TCHAR szTemp[512], szTemp2[512];
TCHAR* pszNick = NULL;
@@ -864,24 +867,15 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce)
_fputts(szLine, hFile);
if (g_Settings.LoggingLimit > 0) {
- long dwSize;
- long trimlimit;
-
fseek(hFile, 0, SEEK_END);
- dwSize = ftell(hFile);
+ long dwSize = ftell(hFile);
rewind(hFile);
- trimlimit = g_Settings.LoggingLimit * 1024;
+ long trimlimit = g_Settings.LoggingLimit * 1024;
if (dwSize > trimlimit) {
- TCHAR tszDrive[_MAX_DRIVE];
- TCHAR tszDir[_MAX_DIR];
- TCHAR tszName[_MAX_FNAME];
- TCHAR tszExt[_MAX_EXT];
- TCHAR tszNewName[_MAX_DRIVE + _MAX_DIR + _MAX_FNAME + _MAX_EXT + 20];
- TCHAR tszNewPath[_MAX_DRIVE + _MAX_DIR + _MAX_FNAME + _MAX_EXT + 20];
- TCHAR tszTimestamp[20];
time_t now = time(0);
+ TCHAR tszTimestamp[20];
_tcsftime(tszTimestamp, 20, _T("%Y%m%d-%H%M%S"), _localtime32((__time32_t *)&now));
tszTimestamp[19] = 0;
/*
@@ -889,12 +883,14 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce)
* move old logs to /archived sub folder just inside the log root folder.
* add a time stamp to the file name.
*/
+ TCHAR tszDrive[_MAX_DRIVE], tszDir[_MAX_DIR], tszName[_MAX_FNAME], tszExt[_MAX_EXT];
_tsplitpath(si->pszLogFileName, tszDrive, tszDir, tszName, tszExt);
- mir_sntprintf(tszNewPath, _MAX_DRIVE + _MAX_DIR + _MAX_FNAME + _MAX_EXT + 20, _T("%s%sarchived\\"),
- tszDrive, tszDir);
-
+ TCHAR tszNewPath[_MAX_DRIVE + _MAX_DIR + _MAX_FNAME + _MAX_EXT + 20];
+ mir_sntprintf(tszNewPath, _MAX_DRIVE + _MAX_DIR + _MAX_FNAME + _MAX_EXT + 20, _T("%s%sarchived\\"), tszDrive, tszDir);
CreateDirectoryTreeT(tszNewPath);
+
+ TCHAR tszNewName[_MAX_DRIVE + _MAX_DIR + _MAX_FNAME + _MAX_EXT + 20];
mir_sntprintf(tszNewName, _MAX_DRIVE + _MAX_DIR + _MAX_FNAME + _MAX_EXT + 20, _T("%s%s-%s%s"), tszNewPath, tszName, tszTimestamp, tszExt);
fclose(hFile);
hFile = 0;
@@ -1157,7 +1153,6 @@ void Chat_SetFilters(SESSION_INFO *si)
if (si == NULL)
return;
- int i;
DWORD dwFlags_default = M.GetDword("Chat", "FilterFlags", 0x03E0);
DWORD dwFlags_local = db_get_dw(si->hContact, "Chat", "FilterFlags", 0x03E0);
DWORD dwMask = db_get_dw(si->hContact, "Chat", "FilterMask", 0);
@@ -1172,7 +1167,7 @@ void Chat_SetFilters(SESSION_INFO *si)
dwMask = db_get_dw(si->hContact, "Chat", "PopupMask", 0);
si->iLogPopupFlags = dwFlags_default;
- for (i=0; i < 32; i++)
+ for (int i=0; i < 32; i++)
if (dwMask & (1 << i))
si->iLogPopupFlags = (dwFlags_local & (1 << i) ? si->iLogPopupFlags | (1 << i) : si->iLogPopupFlags & ~(1 << i));
@@ -1181,7 +1176,7 @@ void Chat_SetFilters(SESSION_INFO *si)
dwMask = db_get_dw(si->hContact, "Chat", "TrayIconMask", 0);
si->iLogTrayFlags = dwFlags_default;
- for (i=0; i < 32; i++)
+ for (int i=0; i < 32; i++)
if (dwMask & (1 << i))
si->iLogTrayFlags = (dwFlags_local & (1 << i) ? si->iLogTrayFlags | (1 << i) : si->iLogTrayFlags & ~(1 << i));