From 00a9149e272b38b002d2a2711c54fab25bcf733f Mon Sep 17 00:00:00 2001
From: George Hazan <george.hazan@gmail.com>
Date: Sat, 18 Jan 2014 12:41:41 +0000
Subject: - log writing fixed; - DoPopup & DoTrayIcons now use inheritance; -
 massive cleaning

git-svn-id: http://svn.miranda-ng.org/main/trunk@7716 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
---
 src/core/stdchat/src/chat.h      | 11 ++++++++--
 src/core/stdchat/src/main.cpp    | 22 ++++++++++++++++++-
 src/core/stdchat/src/manager.cpp | 47 ++++++++++++++++++++++++++++++++++++++++
 src/core/stdchat/src/tools.cpp   | 20 -----------------
 src/core/stdchat/src/window.cpp  | 16 +++++++-------
 5 files changed, 85 insertions(+), 31 deletions(-)

(limited to 'src/core')

diff --git a/src/core/stdchat/src/chat.h b/src/core/stdchat/src/chat.h
index 4b1ce18173..3c3fb68d4e 100644
--- a/src/core/stdchat/src/chat.h
+++ b/src/core/stdchat/src/chat.h
@@ -86,7 +86,11 @@ struct MODULEINFO : public GCModuleInfoBase
 	int OfflineIconIndex;
 };
 
-struct SESSION_INFO : public GCSessionInfoBase {};
+struct SESSION_INFO : public GCSessionInfoBase
+{
+	IAccPropServices* pAccPropServicesForNickList;
+};
+
 struct LOGSTREAMDATA : public GCLogStreamDataBase {};
 
 struct GlobalLogSettings : public GlobalLogSettingsBase
@@ -99,6 +103,7 @@ struct GlobalLogSettings : public GlobalLogSettingsBase
 
 extern GlobalLogSettings g_Settings;
 extern SESSION_INFO g_TabSession;
+extern CHAT_MANAGER saveCI;
 extern TABLIST *g_TabList;
 extern HMENU g_hMenu;
 extern HIMAGELIST hIconsList;
@@ -157,6 +162,9 @@ char* Log_CreateRtfHeader(MODULEINFO * mi);
 INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam);
 int GetTextPixelSize( TCHAR* pszText, HFONT hFont, BOOL bWidth);
 
+SESSION_INFO* SM_GetPrevWindow(SESSION_INFO *si);
+SESSION_INFO* SM_GetNextWindow(SESSION_INFO *si);
+
 // options.c
 int OptionsInitialize(WPARAM wParam, LPARAM lParam);
 void AddIcons(void);
@@ -171,7 +179,6 @@ void CheckColorsInModule(const char* pszModule);
 int  GetRichTextLength(HWND hwnd);
 UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, TCHAR* pszUID, TCHAR* pszWordText);
 void DestroyGCMenu(HMENU *hMenu, int iIndex);
-BOOL DoEventHookAsync(HWND hwnd, const TCHAR *pszID, const char* pszModule, int iType, TCHAR* pszUID, TCHAR* pszText, DWORD dwItem);
 
 // message.c
 char* Message_GetFromStream(HWND hwndDlg, SESSION_INFO *si);
diff --git a/src/core/stdchat/src/main.cpp b/src/core/stdchat/src/main.cpp
index 3fbbc0c281..6c87170a48 100644
--- a/src/core/stdchat/src/main.cpp
+++ b/src/core/stdchat/src/main.cpp
@@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 // globals
 CLIST_INTERFACE *pcli;
-CHAT_MANAGER *pci;
+CHAT_MANAGER *pci, saveCI;
 
 SESSION_INFO g_TabSession;
 HMENU g_hMenu = NULL;
@@ -237,6 +237,20 @@ static void OnFlashWindow(SESSION_INFO *si, int bInactive)
 		SendMessage(g_TabSession.hWnd, GC_SETMESSAGEHIGHLIGHT, 0, (LPARAM)si);
 }
 
+static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce)
+{
+	if (gce->pDest->iType & g_Settings.dwTrayIconFlags)
+		return saveCI.DoTrayIcon(si, gce);
+	return TRUE;
+}
+
+static BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce)
+{
+	if (gce->pDest->iType & g_Settings.dwPopupFlags)
+		return saveCI.DoPopup(si, gce);
+	return TRUE;
+}
+
 static void OnLoadSettings()
 {
 	g_Settings.TabsEnable = db_get_b(NULL, "Chat", "Tabs", 1);
@@ -299,6 +313,8 @@ extern "C" __declspec(dllexport) int Load(void)
 
 	CHAT_MANAGER_INITDATA data = { &g_Settings, sizeof(MODULEINFO), sizeof(SESSION_INFO), LPGENT("Chat module") };
 	mir_getCI(&data);
+	saveCI = *pci;
+
 	pci->OnAddUser = OnAddUser;
 	pci->OnNewUser = OnNewUser;
 	pci->OnRemoveUser = OnRemoveUser;
@@ -321,6 +337,9 @@ extern "C" __declspec(dllexport) int Load(void)
 	pci->OnSetStatusBar = OnSetStatusBar;
 	pci->OnFlashWindow = OnFlashWindow;
 	pci->ShowRoom = ShowRoom;
+
+	pci->DoPopup = DoPopup;
+	pci->DoTrayIcon = DoTrayIcon;
 	pci->ReloadSettings();
 
 	g_hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU));
@@ -341,6 +360,7 @@ extern "C" __declspec(dllexport) int Unload(void)
 	db_set_dw(NULL, "Chat", "roomheight", g_Settings.iHeight);
 
 	DestroyMenu(g_hMenu);
+	*pci = saveCI;
 	return 0;
 }
 
diff --git a/src/core/stdchat/src/manager.cpp b/src/core/stdchat/src/manager.cpp
index 925efde9f8..995011dc42 100644
--- a/src/core/stdchat/src/manager.cpp
+++ b/src/core/stdchat/src/manager.cpp
@@ -24,6 +24,53 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 TABLIST *g_TabList = 0;
 
+SESSION_INFO* SM_GetPrevWindow(SESSION_INFO *si)
+{
+	if (!si)
+		return NULL;
+
+	BOOL bFound = FALSE;
+	SESSION_INFO *pTemp = pci->wndList;
+	while (pTemp != NULL) {
+		if (si == pTemp) {
+			if (bFound)
+				return NULL;
+			else
+				bFound = TRUE;
+		}
+		else if (bFound == TRUE && pTemp->hWnd)
+			return pTemp;
+		pTemp = pTemp->next;
+		if (pTemp == NULL && bFound)
+			pTemp = pci->wndList;
+	}
+	return NULL;
+}
+
+SESSION_INFO* SM_GetNextWindow(SESSION_INFO *si)
+{
+	if (!si)
+		return NULL;
+
+	SESSION_INFO *pTemp = pci->wndList, *pLast = NULL;
+	while (pTemp != NULL) {
+		if (si == pTemp) {
+			if (pLast) {
+				if (pLast != pTemp)
+					return pLast;
+				else
+					return NULL;
+			}
+		}
+		if (pTemp->hWnd)
+			pLast = pTemp;
+		pTemp = pTemp->next;
+		if (pTemp == NULL)
+			pTemp = pci->wndList;
+	}
+	return NULL;
+}
+
 //---------------------------------------------------
 //		Tab list manager functions
 //
diff --git a/src/core/stdchat/src/tools.cpp b/src/core/stdchat/src/tools.cpp
index 072bf6f359..3b29352143 100644
--- a/src/core/stdchat/src/tools.cpp
+++ b/src/core/stdchat/src/tools.cpp
@@ -162,26 +162,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 = pci->SM_FindSession(pszID, pszModule);
-	if (si == NULL)
-		return FALSE;
-
-	GCDEST *gcd = (GCDEST*)mir_calloc(sizeof(GCDEST));
-	gcd->pszModule = mir_strdup(pszModule);
-	gcd->ptszID = mir_tstrdup(pszID);
-	gcd->iType = iType;
-
-	GCHOOK *gch = (GCHOOK*)mir_calloc(sizeof(GCHOOK));
-	gch->ptszUID = mir_tstrdup(pszUID);
-	gch->ptszText = mir_tstrdup(pszText);
-	gch->dwData = dwItem;
-	gch->pDest = gcd;
-	PostMessage(hwnd, GC_FIREHOOK, 0, (LPARAM)gch);
-	return TRUE;
-}
-
 void ValidateFilename(TCHAR *filename)
 {
 	TCHAR *p1 = filename;
diff --git a/src/core/stdchat/src/window.cpp b/src/core/stdchat/src/window.cpp
index 4c622eee41..3e54bcf393 100644
--- a/src/core/stdchat/src/window.cpp
+++ b/src/core/stdchat/src/window.cpp
@@ -341,7 +341,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
 				if (g_Settings.TabsEnable)
 					SendMessage(GetParent(hwnd), GC_SWITCHNEXTTAB, 0, 0);
 				else
-					pci->ShowRoom(pci->SM_GetNextWindow(Parentsi), WINDOW_VISIBLE, TRUE);
+					pci->ShowRoom(SM_GetNextWindow(Parentsi), WINDOW_VISIBLE, TRUE);
 				return TRUE;
 			}
 
@@ -349,7 +349,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
 				if (g_Settings.TabsEnable)
 					SendMessage(GetParent(hwnd), GC_SWITCHPREVTAB, 0, 0);
 				else
-					pci->ShowRoom(pci->SM_GetPrevWindow(Parentsi), WINDOW_VISIBLE, TRUE);
+					pci->ShowRoom(SM_GetPrevWindow(Parentsi), WINDOW_VISIBLE, TRUE);
 				return TRUE;
 			}
 
@@ -1046,11 +1046,11 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
 					break;
 
 				case ID_MESS:
-					DoEventHookAsync(GetParent(hwnd), parentdat->ptszID, parentdat->pszModule, GC_USER_PRIVMESS, ui->pszUID, NULL, 0);
+					pci->DoEventHookAsync(GetParent(hwnd), parentdat->ptszID, parentdat->pszModule, GC_USER_PRIVMESS, ui->pszUID, NULL, 0);
 					break;
 
 				default:
-					DoEventHookAsync(GetParent(hwnd), parentdat->ptszID, parentdat->pszModule, GC_USER_NICKLISTMENU, ui->pszUID, NULL, (LPARAM)uID);
+					pci->DoEventHookAsync(GetParent(hwnd), parentdat->ptszID, parentdat->pszModule, GC_USER_NICKLISTMENU, ui->pszUID, NULL, (LPARAM)uID);
 					break;
 				}
 				DestroyGCMenu(&hMenu, 1);
@@ -2209,7 +2209,7 @@ LABEL_SHOWWINDOW:
 
 					default:
 						PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0 );
-						DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_LOGMENU, NULL, NULL, (LPARAM)uID);
+						pci->DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_LOGMENU, NULL, NULL, (LPARAM)uID);
 						break;
 					}
 					DestroyGCMenu(&hMenu, 5);
@@ -2322,7 +2322,7 @@ LABEL_SHOWWINDOW:
 						SendMessage(GetDlgItem(hwndDlg, IDC_MESSAGE), EM_REPLACESEL, FALSE, (LPARAM)pszName);
 						PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0);
 					}
-					else DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_PRIVMESS, ui->pszUID, NULL, 0);
+					else pci->DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_PRIVMESS, ui->pszUID, NULL, 0);
 				}
 
 				return TRUE;
@@ -2353,7 +2353,7 @@ LABEL_SHOWWINDOW:
 
 				EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
 
-				DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_MESSAGE, NULL, ptszText, 0);
+				pci->DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_MESSAGE, NULL, ptszText, 0);
 				mir_free(pszRtf);
 				mir_free(ptszText);
 				SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGE));
@@ -2430,7 +2430,7 @@ LABEL_SHOWWINDOW:
 		case IDC_CHANMGR:
 			if (!IsWindowEnabled(GetDlgItem(hwndDlg,IDC_CHANMGR)))
 				break;
-			DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_CHANMGR, NULL, NULL, 0);
+			pci->DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_CHANMGR, NULL, NULL, 0);
 			break;
 
 		case IDC_FILTER:
-- 
cgit v1.2.3