From 0c41e6c4566fdb2d99b8a6ca1fb48859fd4a0e34 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 16 Sep 2016 19:43:24 +0000 Subject: - chats services replaces with functions; - chat calls switched from CallServiceSync to direct calls everywhere git-svn-id: http://svn.miranda-ng.org/main/trunk@17305 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/mir_app/src/chat.h | 12 +------- src/mir_app/src/chat_clist.cpp | 11 ++++---- src/mir_app/src/chat_manager.cpp | 15 +++++----- src/mir_app/src/chat_svc.cpp | 59 +++++++++------------------------------- src/mir_app/src/mir_app.def | 5 ++++ src/mir_app/src/mir_app64.def | 5 ++++ 6 files changed, 36 insertions(+), 71 deletions(-) (limited to 'src/mir_app') diff --git a/src/mir_app/src/chat.h b/src/mir_app/src/chat.h index e83904cde8..aff64769ff 100644 --- a/src/mir_app/src/chat.h +++ b/src/mir_app/src/chat.h @@ -27,19 +27,11 @@ struct MODULEINFO : public GCModuleInfoBase {}; struct SESSION_INFO : public GCSessionInfoBase {}; struct LOGSTREAMDATA : public GCLogStreamDataBase {}; -// special service for tweaking performance -#define MS_GC_GETEVENTPTR "GChat/GetNewEventPtr" -typedef INT_PTR(*GETEVENTFUNC)(WPARAM wParam, LPARAM lParam); -struct GCPTRS -{ - GETEVENTFUNC pfnAddEvent; -}; - extern HGENMENU hJoinMenuItem, hLeaveMenuItem; extern GlobalLogSettingsBase *g_Settings; extern int g_cbSession, g_cbModuleInfo, g_iFontMode, g_iChatLang; extern wchar_t *g_szFontGroup; -extern mir_cs cs; +extern mir_cs csChat; extern char* pLogIconBmpBits[14]; @@ -61,11 +53,9 @@ BOOL SetAllOffline(BOOL bHide, const char *pszModule); BOOL SetOffline(MCONTACT hContact, BOOL bHide); int RoomDoubleclicked(WPARAM wParam,LPARAM lParam); -INT_PTR EventDoubleclicked(WPARAM wParam,LPARAM lParam); INT_PTR JoinChat(WPARAM wParam, LPARAM lParam); INT_PTR LeaveChat(WPARAM wParam, LPARAM lParam); int PrebuildContactMenu(WPARAM wParam, LPARAM lParam); -INT_PTR PrebuildContactMenuSvc(WPARAM wParam, LPARAM lParam); // colorchooser.c void ColorChooser(SESSION_INFO *si, BOOL bFG, HWND hwndDlg, HWND hwndTarget, HWND hwndChooser); diff --git a/src/mir_app/src/chat_clist.cpp b/src/mir_app/src/chat_clist.cpp index d371083f5f..b6fdad1875 100644 --- a/src/mir_app/src/chat_clist.cpp +++ b/src/mir_app/src/chat_clist.cpp @@ -131,7 +131,7 @@ int RoomDoubleclicked(WPARAM hContact, LPARAM) return 1; } -INT_PTR EventDoubleclicked(WPARAM,LPARAM lParam) +static INT_PTR EventDoubleclicked(WPARAM,LPARAM lParam) { return RoomDoubleclicked((WPARAM)((CLISTEVENT*)lParam)->hContact, 0); } @@ -193,11 +193,6 @@ int PrebuildContactMenu(WPARAM hContact, LPARAM) return 0; } -INT_PTR PrebuildContactMenuSvc(WPARAM wParam, LPARAM lParam) -{ - return PrebuildContactMenu(wParam, lParam); -} - BOOL AddEvent(MCONTACT hContact, HICON hIcon, MEVENT hEvent, int type, wchar_t* fmt, ...) { wchar_t szBuf[4096]; @@ -217,6 +212,10 @@ BOOL AddEvent(MCONTACT hContact, HICON hIcon, MEVENT hEvent, int type, wchar_t* cle.hIcon = hIcon; cle.pszService = "GChat/DblClickEvent" ; cle.ptszTooltip = TranslateW(szBuf); + + if (!ServiceExists(cle.pszService)) + CreateServiceFunction(cle.pszService, &EventDoubleclicked); + if (type) { if (!cli.pfnGetEvent(hContact, 0)) cli.pfnAddEvent(&cle); diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index 3ec71e4886..79659bd7ef 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -1179,17 +1179,16 @@ static BOOL LM_RemoveAll(LOGINFO **ppLogListStart, LOGINFO **ppLogListEnd) return TRUE; } -INT_PTR SvcGetChatManager(WPARAM wParam, LPARAM lParam) +MIR_APP_DLL(CHAT_MANAGER*) Chat_GetInterface(CHAT_MANAGER_INITDATA *pInit, int _hLangpack) { - if (lParam == NULL) - return (INT_PTR)&chatApi; + if (pInit == NULL) + return &chatApi; // wipe out old junk memset(PBYTE(&chatApi) + offsetof(CHAT_MANAGER, OnCreateModule), 0, sizeof(CHAT_MANAGER) - offsetof(CHAT_MANAGER, OnCreateModule)); - CHAT_MANAGER_INITDATA *pInit = (CHAT_MANAGER_INITDATA*)lParam; if (g_cbSession) { // reallocate old sessions - mir_cslock lck(cs); + mir_cslock lck(csChat); SESSION_INFO *pPrev = NULL; for (SESSION_INFO *p = chatApi.wndList; p; p = p->next) { SESSION_INFO *p1 = (SESSION_INFO*)mir_realloc(p, pInit->cbSession); @@ -1205,7 +1204,7 @@ INT_PTR SvcGetChatManager(WPARAM wParam, LPARAM lParam) } } if (g_cbModuleInfo) { // reallocate old modules - mir_cslock lck(cs); + mir_cslock lck(csChat); MODULEINFO *pPrev = NULL; for (MODULEINFO *p = m_ModList; p; p = p->next) { MODULEINFO *p1 = (MODULEINFO*)mir_realloc(p, pInit->cbModuleInfo); @@ -1225,7 +1224,7 @@ INT_PTR SvcGetChatManager(WPARAM wParam, LPARAM lParam) g_cbSession = pInit->cbSession; g_cbModuleInfo = pInit->cbModuleInfo; g_iFontMode = pInit->iFontMode; - g_iChatLang = (int)wParam; + g_iChatLang = _hLangpack; chatApi.SetActiveSession = SetActiveSession; chatApi.SetActiveSessionEx = SetActiveSessionEx; @@ -1326,5 +1325,5 @@ INT_PTR SvcGetChatManager(WPARAM wParam, LPARAM lParam) RegisterFonts(); OptionsInit(); - return (INT_PTR)&chatApi; + return &chatApi; } diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index 58fdbb1bb3..0e390c90e4 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -27,7 +27,7 @@ INT_PTR SvcGetChatManager(WPARAM, LPARAM); #include "chat.h" HGENMENU hJoinMenuItem, hLeaveMenuItem; -mir_cs cs; +mir_cs csChat; static HANDLE hServiceRegister = NULL, @@ -119,22 +119,12 @@ static int SmileyOptionsChanged(WPARAM, LPARAM) return 0; } -static INT_PTR Service_GetCount(WPARAM, LPARAM lParam) +EXTERN_C MIR_APP_DLL(int) Chat_GetInfo(GC_INFO *gci) { - if (!lParam) - return -1; - - mir_cslock lck(cs); - return chatApi.SM_GetCount((char *)lParam); -} - -static INT_PTR Service_GetInfo(WPARAM, LPARAM lParam) -{ - GC_INFO *gci = (GC_INFO *)lParam; if (!gci || !gci->pszModule) return 1; - mir_cslock lck(cs); + mir_cslock lck(csChat); SESSION_INFO *si; if (gci->Flags & GCF_BYINDEX) @@ -154,16 +144,15 @@ static INT_PTR Service_GetInfo(WPARAM, LPARAM lParam) return 0; } -static INT_PTR Service_Register(WPARAM, LPARAM lParam) +MIR_APP_DLL(int) Chat_Register(const GCREGISTER *gcr) { - GCREGISTER *gcr = (GCREGISTER *)lParam; if (gcr == NULL) return GC_REGISTER_ERROR; if (gcr->cbSize != sizeof(GCREGISTER)) return GC_REGISTER_WRONGVER; - mir_cslock lck(cs); + mir_cslock lck(csChat); MODULEINFO *mi = chatApi.MM_AddModule(gcr->pszModule); if (mi == NULL) return GC_REGISTER_ERROR; @@ -192,16 +181,15 @@ static INT_PTR Service_Register(WPARAM, LPARAM lParam) return 0; } -static INT_PTR Service_NewChat(WPARAM, LPARAM lParam) +EXTERN_C MIR_APP_DLL(int) Chat_NewSession(const GCSESSION *gcw) { - GCSESSION *gcw = (GCSESSION *)lParam; if (gcw == NULL) return GC_NEWSESSION_ERROR; if (gcw->cbSize != sizeof(GCSESSION)) return GC_NEWSESSION_WRONGVER; - mir_cslock lck(cs); + mir_cslock lck(csChat); MODULEINFO *mi = chatApi.MM_FindModule(gcw->pszModule); if (mi == NULL) return GC_NEWSESSION_ERROR; @@ -399,9 +387,8 @@ static void AddUser(GCEVENT *gce) chatApi.OnNewUser(si, ui); } -static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) +EXTERN_C MIR_APP_DLL(int) Chat_Event(int sessionEvent, GCEVENT *gce) { - GCEVENT *gce = (GCEVENT*)lParam; BOOL bIsHighlighted = FALSE; BOOL bRemoveFlag = FALSE; @@ -418,10 +405,10 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) if (!IsEventSupported(gcd->iType)) return GC_EVENT_ERROR; - if (NotifyEventHooks(hHookEvent, wParam, lParam)) + if (NotifyEventHooks(hHookEvent, 0, LPARAM(gce))) return 1; - mir_cslock lck(cs); + mir_cslock lck(csChat); // Do different things according to type of event switch (gcd->iType) { @@ -442,7 +429,7 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) case GC_EVENT_ACK: case GC_EVENT_SENDMESSAGE: case GC_EVENT_SETSTATUSEX: - return DoControl(gce, wParam); + return DoControl(gce, sessionEvent); case GC_EVENT_SETCONTACTSTATUS: return chatApi.SM_SetContactStatus(gcd->ptszID, gcd->pszModule, gce->ptszUID, (WORD)gce->dwItemData); @@ -549,15 +536,6 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) return GC_EVENT_ERROR; } -static INT_PTR Service_GetAddEventPtr(WPARAM, LPARAM lParam) -{ - GCPTRS *gp = (GCPTRS *)lParam; - - mir_cslock lck(cs); - gp->pfnAddEvent = Service_AddEvent; - return 0; -} - static int ModulesLoaded(WPARAM, LPARAM) { LoadChatIcons(); @@ -573,6 +551,7 @@ static int ModulesLoaded(WPARAM, LPARAM) mi.name.a = LPGEN("&Join chat"); mi.pszService = "GChat/JoinChat"; hJoinMenuItem = Menu_AddContactMenuItem(&mi); + CreateServiceFunction(mi.pszService, JoinChat); SET_UID(mi, 0x72b7440b, 0xd2db, 0x4e22, 0xa6, 0xb1, 0x2, 0xd0, 0x96, 0xee, 0xad, 0x88); mi.position = -2000090000; @@ -581,6 +560,7 @@ static int ModulesLoaded(WPARAM, LPARAM) mi.name.a = LPGEN("&Leave chat"); mi.pszService = "GChat/LeaveChat"; hLeaveMenuItem = Menu_AddContactMenuItem(&mi); + CreateServiceFunction(mi.pszService, LeaveChat); chatApi.SetAllOffline(TRUE, NULL); return 0; @@ -597,19 +577,6 @@ int LoadChatModule(void) HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown); HookEvent(ME_SKIN_ICONSCHANGED, IconsChanged); - CreateServiceFunction(MS_GC_REGISTER, Service_Register); - CreateServiceFunction(MS_GC_NEWSESSION, Service_NewChat); - CreateServiceFunction(MS_GC_EVENT, Service_AddEvent); - CreateServiceFunction(MS_GC_GETEVENTPTR, Service_GetAddEventPtr); - CreateServiceFunction(MS_GC_GETINFO, Service_GetInfo); - CreateServiceFunction(MS_GC_GETSESSIONCOUNT, Service_GetCount); - - CreateServiceFunction("GChat/DblClickEvent", EventDoubleclicked); - CreateServiceFunction("GChat/PrebuildMenuEvent", PrebuildContactMenuSvc); - CreateServiceFunction("GChat/JoinChat", JoinChat); - CreateServiceFunction("GChat/LeaveChat", LeaveChat); - CreateServiceFunction("GChat/GetInterface", SvcGetChatManager); - chatApi.hSendEvent = CreateHookableEvent(ME_GC_EVENT); chatApi.hBuildMenuEvent = CreateHookableEvent(ME_GC_BUILDMENU); hHookEvent = CreateHookableEvent(ME_GC_HOOK_EVENT); diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 0d2942d84f..dd066e34da 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -295,3 +295,8 @@ DestroyDbInstance @295 FindDatabasePlugin @296 InitDbInstance @297 RegisterDatabasePlugin @298 +Chat_GetInterface @299 +Chat_Event @300 +Chat_GetInfo @301 +Chat_NewSession @302 +Chat_Register @303 diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index e7ff36afca..de2bdb2cbe 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -295,3 +295,8 @@ DestroyDbInstance @295 FindDatabasePlugin @296 InitDbInstance @297 RegisterDatabasePlugin @298 +Chat_GetInterface @299 +Chat_Event @300 +Chat_GetInfo @301 +Chat_NewSession @302 +Chat_Register @303 -- cgit v1.2.3