diff options
Diffstat (limited to 'plugins/TabSRMM/src/chat/main.cpp')
-rw-r--r-- | plugins/TabSRMM/src/chat/main.cpp | 284 |
1 files changed, 219 insertions, 65 deletions
diff --git a/plugins/TabSRMM/src/chat/main.cpp b/plugins/TabSRMM/src/chat/main.cpp index 63d41a9599..4adb98d5f3 100644 --- a/plugins/TabSRMM/src/chat/main.cpp +++ b/plugins/TabSRMM/src/chat/main.cpp @@ -36,88 +36,242 @@ HANDLE g_hWindowList;
HMENU g_hMenu = NULL;
-FONTINFO aFonts[OPTIONS_FONTCOUNT];
-HICON hIcons[30];
-HBRUSH hListBkgBrush = NULL;
-
+CHAT_MANAGER *pci;
TMUCSettings g_Settings;
-TCHAR *pszActiveWndID = 0;
-char *pszActiveWndModule = 0;
+static void OnAddLog(SESSION_INFO *si, int isOk)
+{
+ if (isOk && si->hWnd)
+ SendMessage(si->hWnd, GC_ADDLOG, 0, 0);
+ else if (si->hWnd)
+ SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0);
+}
-/*
- * load the group chat module
- */
+static void OnCreateSession(SESSION_INFO *si, MODULEINFO *mi)
+{
+ si->Highlight = g_Settings.Highlight;
+ if (mi) {
+ mi->idleTimeStamp = time(0);
+ pci->SM_BroadcastMessage(mi->pszModule, GC_UPDATESTATUSBAR, 0, 1, TRUE);
+ }
+}
-int Chat_Load()
+static void OnSessionDblClick(SESSION_INFO *si)
{
- g_hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU));
- if (CreateServiceFunctions()) {
- HookEvents();
- CreateHookableEvents();
- OptionsInit();
+ PostMessage(si->hWnd, GC_CLOSEWINDOW, 0, 0);
+}
+
+static void OnSessionRemove(SESSION_INFO *si)
+{
+ if (si->hWnd)
+ SendMessage(si->hWnd, GC_EVENT_CONTROL + WM_USER + 500, SESSION_TERMINATE, 0);
+}
+
+static void OnSessionRename(SESSION_INFO *si)
+{
+ if (si->hWnd)
+ SendMessage(si->hWnd, GC_UPDATETITLE, 0, 0);
+}
+
+static void OnSessionReplace(SESSION_INFO *si)
+{
+ if (si->hContact)
+ Chat_SetFilters(si);
+ if (si->hWnd)
+ RedrawWindow(GetDlgItem(si->hWnd, IDC_LIST), NULL, NULL, RDW_INVALIDATE);
+}
+
+static void OnEventBroadcast(SESSION_INFO *si, GCEVENT *gce)
+{
+ if (pci->SM_AddEvent(si->ptszID, si->pszModule, gce, FALSE) && si->hWnd && si->bInitDone)
+ SendMessage(si->hWnd, GC_ADDLOG, 0, 0);
+ else if (si->hWnd && si->bInitDone)
+ SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0);
+}
+
+static void OnSetTopic(SESSION_INFO *si)
+{
+ if (si->hWnd)
+ SendMessage(si->hWnd, DM_INVALIDATEPANEL, 0, 0);
+}
+
+static void OnSetStatusBar(SESSION_INFO *si)
+{
+ if (si->hWnd)
+ SendMessage(si->hWnd, GC_UPDATESTATUSBAR, 0, 0);
+}
+
+static void OnNewUser(SESSION_INFO *si, USERINFO*)
+{
+ if (si->hWnd) {
+ SendMessage(si->hWnd, GC_UPDATENICKLIST, 0, 0);
+ if (si->dat)
+ GetMyNick(si->dat);
}
- return 0;
}
-/*
- * unload the module. final cleanup
- */
+static void OnChangeNick(SESSION_INFO *si)
+{
+ if (si->hWnd) {
+ if (si->dat)
+ GetMyNick(si->dat);
+ SendMessage(si->hWnd, GC_UPDATESTATUSBAR, 0, 0);
+ }
+}
-int Chat_Unload(void)
+static void OnSetStatus(SESSION_INFO *si, int wStatus)
{
- db_set_w(NULL, "Chat", "SplitterX", (WORD)g_Settings.iSplitterX);
- db_set_w(NULL, "Chat", "splitY", (WORD)g_Settings.iSplitterY);
+ PostMessage(si->hWnd, GC_FIXTABICONS, 0, 0);
+}
- CList_SetAllOffline(TRUE, NULL);
+static void OnCreateModule(MODULEINFO *mi)
+{
+ mi->idleTimeStamp = time(0);
+}
- mir_free(pszActiveWndID);
- mir_free(pszActiveWndModule);
+static void OnLoadSettings()
+{
+ LOGFONT lf;
+ char szBuf[40];
- DestroyMenu(g_hMenu);
- DestroyHookableEvents();
- FreeIcons();
- OptionsUnInit();
- UnhookEvents();
- return 0;
+ g_Settings.iEventLimitThreshold = db_get_w(NULL, "Chat", "LogLimitThreshold", 20);
+ g_Settings.dwIconFlags = M.GetDword("Chat", "IconFlags", 0x0000);
+ g_Settings.bOpenInDefault = M.GetBool("Chat", "DefaultContainer", true);
+ g_Settings.bFlashWindowHightlight = M.GetBool("Chat", "FlashWindowHighlight", false);
+ g_Settings.UserListColors[CHAT_STATUS_NORMAL] = M.GetDword(CHAT_FONTMODULE, "Font18Col", RGB(0, 0, 0));
+ g_Settings.UserListColors[CHAT_STATUS_AWAY] = M.GetDword(CHAT_FONTMODULE, "Font19Col", RGB(170, 170, 170));
+ g_Settings.UserListColors[CHAT_STATUS_OFFLINE] = M.GetDword(CHAT_FONTMODULE, "Font5Col", RGB(160, 90, 90));
+ g_Settings.bBBCodeInPopups = M.GetByte("Chat", "BBCodeInPopups", 0) != 0;
+ g_Settings.bClassicIndicators = M.GetBool("Chat", "ClassicIndicators", false);
+ g_Settings.bLogClassicIndicators = M.GetBool("Chat", "LogClassicIndicators", false);
+ g_Settings.bAlternativeSorting = M.GetBool("Chat", "AlternativeSorting", true);
+ g_Settings.bAnnoyingHighlight = M.GetBool("Chat", "AnnoyingHighlight", false);
+ g_Settings.bCreateWindowOnHighlight = M.GetBool("Chat", "CreateWindowOnHighlight", true);
+
+ g_Settings.bLogSymbols = M.GetBool("Chat", "LogSymbols", true);
+ g_Settings.bClickableNicks = M.GetBool("Chat", "ClickableNicks", true);
+ g_Settings.bColorizeNicks = M.GetBool("Chat", "ColorizeNicks", true);
+ g_Settings.bColorizeNicksInLog = M.GetBool("Chat", "ColorizeNicksInLog", true);
+ g_Settings.bScaleIcons = M.GetBool("Chat", "ScaleIcons", true);
+ g_Settings.bUseDividers = M.GetBool("Chat", "UseDividers", true);
+ g_Settings.bDividersUsePopupConfig = M.GetBool("Chat", "DividersUsePopupConfig", true);
+
+ g_Settings.bDoubleClick4Privat = M.GetBool("Chat", "DoubleClick4Privat", false);
+ g_Settings.bShowContactStatus = M.GetBool("Chat", "ShowContactStatus", true);
+ g_Settings.bContactStatusFirst = M.GetBool("Chat", "ContactStatusFirst", false);
+
+ // nicklist
+ if (g_Settings.UserListFonts[0]) {
+ DeleteObject(g_Settings.UserListFonts[CHAT_STATUS_NORMAL]);
+ DeleteObject(g_Settings.UserListFonts[CHAT_STATUS_AWAY]);
+ DeleteObject(g_Settings.UserListFonts[CHAT_STATUS_OFFLINE]);
+ }
+
+ LoadMsgDlgFont(FONTSECTION_CHAT, 18, &lf, NULL, CHAT_FONTMODULE);
+ g_Settings.UserListFonts[CHAT_STATUS_NORMAL] = CreateFontIndirect(&lf);
+
+ LoadMsgDlgFont(FONTSECTION_CHAT, 19, &lf, NULL, CHAT_FONTMODULE);
+ g_Settings.UserListFonts[CHAT_STATUS_AWAY] = CreateFontIndirect(&lf);
+
+ LoadMsgDlgFont(FONTSECTION_CHAT, 5, &lf, NULL, CHAT_FONTMODULE);
+ g_Settings.UserListFonts[CHAT_STATUS_OFFLINE] = CreateFontIndirect(&lf);
+
+ int ih = GetTextPixelSize(_T("AQGglo"), g_Settings.UserListFonts[CHAT_STATUS_NORMAL], false);
+ int ih2 = GetTextPixelSize(_T("AQGglo"), g_Settings.UserListFonts[CHAT_STATUS_AWAY], false);
+ g_Settings.iNickListFontHeight = max(M.GetByte("Chat", "NicklistRowDist", 12), (ih > ih2 ? ih : ih2));
+
+ for (int i = 0; i < 7; i++) {
+ mir_snprintf(szBuf, 20, "NickColor%d", i);
+ g_Settings.nickColors[i] = M.GetDword("Chat", szBuf, g_Settings.UserListColors[0]);
+ }
+ g_Settings.nickColors[5] = M.GetDword("Chat", "NickColor5", GetSysColor(COLOR_HIGHLIGHT));
+ g_Settings.nickColors[6] = M.GetDword("Chat", "NickColor6", GetSysColor(COLOR_HIGHLIGHTTEXT));
+
+ if (g_Settings.SelectionBGBrush)
+ DeleteObject(g_Settings.SelectionBGBrush);
+ g_Settings.SelectionBGBrush = CreateSolidBrush(g_Settings.nickColors[5]);
+
+ Log_SetStyles();
}
-void LoadLogIcons(void)
-{
- ZeroMemory(hIcons, sizeof(HICON) * (ICON_STATUS5 - ICON_ACTION));
- hIcons[ICON_ACTION] = LoadIconEx(IDI_ACTION, "log_action", 16, 16);
- hIcons[ICON_ADDSTATUS] = LoadIconEx(IDI_ADDSTATUS, "log_addstatus", 16, 16);
- hIcons[ICON_HIGHLIGHT] = LoadIconEx(IDI_HIGHLIGHT, "log_highlight", 16, 16);
- hIcons[ICON_INFO] = LoadIconEx(IDI_INFO, "log_info", 16, 16);
- hIcons[ICON_JOIN] = LoadIconEx(IDI_JOIN, "log_join", 16, 16);
- hIcons[ICON_KICK] = LoadIconEx(IDI_KICK, "log_kick", 16, 16);
- hIcons[ICON_MESSAGE] = LoadIconEx(IDI_MESSAGE, "log_message_in", 16, 16);
- hIcons[ICON_MESSAGEOUT] = LoadIconEx(IDI_MESSAGEOUT, "log_message_out", 16, 16);
- hIcons[ICON_NICK] = LoadIconEx(IDI_NICK, "log_nick", 16, 16);
- hIcons[ICON_NOTICE] = LoadIconEx(IDI_NOTICE, "log_notice", 16, 16);
- hIcons[ICON_PART] = LoadIconEx(IDI_PART, "log_part", 16, 16);
- hIcons[ICON_QUIT] = LoadIconEx(IDI_QUIT, "log_quit", 16, 16);
- hIcons[ICON_REMSTATUS] = LoadIconEx(IDI_REMSTATUS, "log_removestatus", 16, 16);
- hIcons[ICON_TOPIC] = LoadIconEx(IDI_TOPIC, "log_topic", 16, 16);
- hIcons[ICON_STATUS1] = LoadIconEx(IDI_STATUS1, "status1", 16, 16);
- hIcons[ICON_STATUS2] = LoadIconEx(IDI_STATUS2, "status2", 16, 16);
- hIcons[ICON_STATUS3] = LoadIconEx(IDI_STATUS3, "status3", 16, 16);
- hIcons[ICON_STATUS4] = LoadIconEx(IDI_STATUS4, "status4", 16, 16);
- hIcons[ICON_STATUS0] = LoadIconEx(IDI_STATUS0, "status0", 16, 16);
- hIcons[ICON_STATUS5] = LoadIconEx(IDI_STATUS5, "status5", 16, 16);
-}
-
-void LoadIcons(void)
-{
- for (int i=0; i < 20; i++)
- hIcons[i] = NULL;
-
- LoadLogIcons();
+/////////////////////////////////////////////////////////////////////////////////////////
+
+void Chat_ModulesLoaded()
+{
+ ZeroMemory(pci->hIcons, sizeof(HICON)* (ICON_STATUS5 - ICON_ACTION));
+ pci->hIcons[ICON_ACTION] = LoadIconEx(IDI_ACTION, "log_action", 16, 16);
+ pci->hIcons[ICON_ADDSTATUS] = LoadIconEx(IDI_ADDSTATUS, "log_addstatus", 16, 16);
+ pci->hIcons[ICON_HIGHLIGHT] = LoadIconEx(IDI_HIGHLIGHT, "log_highlight", 16, 16);
+ pci->hIcons[ICON_INFO] = LoadIconEx(IDI_INFO, "log_info", 16, 16);
+ pci->hIcons[ICON_JOIN] = LoadIconEx(IDI_JOIN, "log_join", 16, 16);
+ pci->hIcons[ICON_KICK] = LoadIconEx(IDI_KICK, "log_kick", 16, 16);
+ pci->hIcons[ICON_MESSAGE] = LoadIconEx(IDI_MESSAGE, "log_message_in", 16, 16);
+ pci->hIcons[ICON_MESSAGEOUT] = LoadIconEx(IDI_MESSAGEOUT, "log_message_out", 16, 16);
+ pci->hIcons[ICON_NICK] = LoadIconEx(IDI_NICK, "log_nick", 16, 16);
+ pci->hIcons[ICON_NOTICE] = LoadIconEx(IDI_NOTICE, "log_notice", 16, 16);
+ pci->hIcons[ICON_PART] = LoadIconEx(IDI_PART, "log_part", 16, 16);
+ pci->hIcons[ICON_QUIT] = LoadIconEx(IDI_QUIT, "log_quit", 16, 16);
+ pci->hIcons[ICON_REMSTATUS] = LoadIconEx(IDI_REMSTATUS, "log_removestatus", 16, 16);
+ pci->hIcons[ICON_TOPIC] = LoadIconEx(IDI_TOPIC, "log_topic", 16, 16);
+ pci->hIcons[ICON_STATUS1] = LoadIconEx(IDI_STATUS1, "status1", 16, 16);
+ pci->hIcons[ICON_STATUS2] = LoadIconEx(IDI_STATUS2, "status2", 16, 16);
+ pci->hIcons[ICON_STATUS3] = LoadIconEx(IDI_STATUS3, "status3", 16, 16);
+ pci->hIcons[ICON_STATUS4] = LoadIconEx(IDI_STATUS4, "status4", 16, 16);
+ pci->hIcons[ICON_STATUS0] = LoadIconEx(IDI_STATUS0, "status0", 16, 16);
+ pci->hIcons[ICON_STATUS5] = LoadIconEx(IDI_STATUS5, "status5", 16, 16);
+
g_Settings.hIconOverlay = LoadIconEx(IDI_OVERLAY, "overlay", 16, 16);
- LoadMsgLogBitmaps();
}
-void FreeIcons(void)
+/////////////////////////////////////////////////////////////////////////////////////////
+// load the group chat module
+
+static CHAT_MANAGER saveCI;
+
+int Chat_Load()
{
- FreeMsgLogBitmaps();
+ mir_getCI(&g_Settings);
+ saveCI = *pci;
+ pci->cbModuleInfo = sizeof(MODULEINFO);
+ pci->cbSession = sizeof(SESSION_INFO);
+ pci->OnCreateModule = OnCreateModule;
+ pci->OnNewUser = OnNewUser;
+
+ pci->OnSetStatus = OnSetStatus;
+ pci->OnSetTopic = OnSetTopic;
+
+ pci->OnAddLog = OnAddLog;
+
+ pci->OnCreateSession = OnCreateSession;
+ pci->OnSessionRemove = OnSessionRemove;
+ pci->OnSessionRename = OnSessionRename;
+ pci->OnSessionReplace = OnSessionReplace;
+ pci->OnSessionDblClick = OnSessionDblClick;
+
+ pci->OnEventBroadcast = OnEventBroadcast;
+ pci->OnSetStatusBar = OnSetStatusBar;
+ pci->OnChangeNick = OnChangeNick;
+ pci->ShowRoom = ShowRoom;
+ pci->OnLoadSettings = OnLoadSettings;
+
+ // this operation is unsafe, that's why we restore the old pci state on exit
+ pci->DoSoundsFlashPopupTrayStuff = DoSoundsFlashPopupTrayStuff;
+
+ g_hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU));
+
+ OnLoadSettings();
+ OptionsInit();
+ return 0;
+}
+
+/*
+ * unload the module. final cleanup
+ */
+
+int Chat_Unload(void)
+{
+ *pci = saveCI;
+ DestroyMenu(g_hMenu);
+ OptionsUnInit();
+ return 0;
}
|