diff options
author | George Hazan <ghazan@miranda.im> | 2018-05-20 00:17:30 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-05-20 00:17:30 +0300 |
commit | 7deea6cec5d2173f66d4c2dd75ca0b633b887bc7 (patch) | |
tree | 8e95a2e5a707ef578c2f070b997156fcda6f088c /src | |
parent | 15051a110d2575c2baa9a3b358977000c876abd9 (diff) |
sounds packed into CMPlugin (reduces usage of hLangpack)
Diffstat (limited to 'src')
-rw-r--r-- | src/core/stdfile/src/file.cpp | 8 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgs.cpp | 14 | ||||
-rw-r--r-- | src/core/stduseronline/src/useronline.cpp | 3 | ||||
-rw-r--r-- | src/mir_app/src/CMPluginBase.cpp | 49 | ||||
-rw-r--r-- | src/mir_app/src/auth.cpp | 4 | ||||
-rw-r--r-- | src/mir_app/src/chat_opts.cpp | 22 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 5 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 5 | ||||
-rw-r--r-- | src/mir_app/src/miranda.h | 2 | ||||
-rw-r--r-- | src/mir_app/src/sounds.cpp | 4 | ||||
-rw-r--r-- | src/mir_core/src/mir_core.def | 4 | ||||
-rw-r--r-- | src/mir_core/src/mir_core64.def | 4 | ||||
-rw-r--r-- | src/mir_core/src/miranda.cpp | 3 | ||||
-rw-r--r-- | src/mir_core/src/modules.cpp | 49 |
14 files changed, 88 insertions, 88 deletions
diff --git a/src/core/stdfile/src/file.cpp b/src/core/stdfile/src/file.cpp index 9dda11aa92..4b39aff9b0 100644 --- a/src/core/stdfile/src/file.cpp +++ b/src/core/stdfile/src/file.cpp @@ -442,9 +442,9 @@ int LoadSendRecvFileModule(void) CreateServiceFunction("SRFile/OpenContRecDir", openContRecDir);
CreateServiceFunction("SRFile/OpenRecDir", openRecDir);
- Skin_AddSound("RecvFile", LPGENW("File"), LPGENW("Incoming"));
- Skin_AddSound("FileDone", LPGENW("File"), LPGENW("Complete"));
- Skin_AddSound("FileFailed", LPGENW("File"), LPGENW("Error"));
- Skin_AddSound("FileDenied", LPGENW("File"), LPGENW("Denied"));
+ g_plugin.addSound("RecvFile", LPGENW("File"), LPGENW("Incoming"));
+ g_plugin.addSound("FileDone", LPGENW("File"), LPGENW("Complete"));
+ g_plugin.addSound("FileFailed", LPGENW("File"), LPGENW("Error"));
+ g_plugin.addSound("FileDenied", LPGENW("File"), LPGENW("Denied"));
return 0;
}
diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index 0b982e5892..36ef8201bb 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -538,13 +538,13 @@ int LoadSendRecvMessageModule(void) CreateServiceFunction(MS_MSG_SENDMESSAGEW, SendMessageCommand_W);
CreateServiceFunction(MS_MSG_READMESSAGE, ReadMessageCommand);
- Skin_AddSound("RecvMsgActive", LPGENW("Instant messages"), LPGENW("Incoming (focused window)"));
- Skin_AddSound("RecvMsgInactive", LPGENW("Instant messages"), LPGENW("Incoming (unfocused window)"));
- Skin_AddSound("AlertMsg", LPGENW("Instant messages"), LPGENW("Incoming (new session)"));
- Skin_AddSound("SendMsg", LPGENW("Instant messages"), LPGENW("Outgoing"));
- Skin_AddSound("SendError", LPGENW("Instant messages"), LPGENW("Message send error"));
- Skin_AddSound("TNStart", LPGENW("Instant messages"), LPGENW("Contact started typing"));
- Skin_AddSound("TNStop", LPGENW("Instant messages"), LPGENW("Contact stopped typing"));
+ g_plugin.addSound("RecvMsgActive", LPGENW("Instant messages"), LPGENW("Incoming (focused window)"));
+ g_plugin.addSound("RecvMsgInactive", LPGENW("Instant messages"), LPGENW("Incoming (unfocused window)"));
+ g_plugin.addSound("AlertMsg", LPGENW("Instant messages"), LPGENW("Incoming (new session)"));
+ g_plugin.addSound("SendMsg", LPGENW("Instant messages"), LPGENW("Outgoing"));
+ g_plugin.addSound("SendError", LPGENW("Instant messages"), LPGENW("Message send error"));
+ g_plugin.addSound("TNStart", LPGENW("Instant messages"), LPGENW("Contact started typing"));
+ g_plugin.addSound("TNStop", LPGENW("Instant messages"), LPGENW("Contact stopped typing"));
InitStatusIcons();
return 0;
diff --git a/src/core/stduseronline/src/useronline.cpp b/src/core/stduseronline/src/useronline.cpp index 54063cb44c..163b705835 100644 --- a/src/core/stduseronline/src/useronline.cpp +++ b/src/core/stduseronline/src/useronline.cpp @@ -112,6 +112,7 @@ int LoadUserOnlineModule(void) HookEvent(ME_PROTO_ACK, UserOnlineAck);
HookEvent(ME_SYSTEM_MODULESLOADED, UserOnlineModulesLoaded);
HookEvent(ME_PROTO_ACCLISTCHANGED, UserOnlineAccountsChanged);
- Skin_AddSound(MODULENAME, LPGENW("Alerts"), LPGENW("Online"));
+
+ g_plugin.addSound(MODULENAME, LPGENW("Alerts"), LPGENW("Online"));
return 0;
}
diff --git a/src/mir_app/src/CMPluginBase.cpp b/src/mir_app/src/CMPluginBase.cpp index 6fc1b0c689..fd7174a1bb 100644 --- a/src/mir_app/src/CMPluginBase.cpp +++ b/src/mir_app/src/CMPluginBase.cpp @@ -24,10 +24,55 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" +static LIST<CMPluginBase> pluginListAddr(10, HandleKeySortT); + +void RegisterModule(CMPluginBase *pPlugin) +{ + pluginListAddr.insert(pPlugin); +} + +MIR_APP_DLL(HINSTANCE) GetInstByAddress(void* codePtr) +{ + if (pluginListAddr.getCount() == 0) + return nullptr; + + int idx; + List_GetIndex((SortedList*)&pluginListAddr, (CMPluginBase*)&codePtr, &idx); + if (idx > 0) + idx--; + + HINSTANCE result = pluginListAddr[idx]->getInst(); + if (result < g_plugin.getInst() && codePtr > g_plugin.getInst()) + return g_plugin.getInst(); + + if (idx == 0 && codePtr < (void*)result) + return nullptr; + + return result; +} + +MIR_APP_DLL(CMPluginBase*) GetPluginByLangId(int _hLang) +{ + for (auto &it : pluginListAddr) + if (it->m_hLang == _hLang) + return it; + + return nullptr; +} + +MIR_APP_DLL(CMPluginBase&) GetPluginByInstance(HINSTANCE hInst) +{ + CMPluginBase *pPlugin = pluginListAddr.find((CMPluginBase*)&hInst); + return (pPlugin == nullptr) ? g_plugin : *pPlugin; +} + +///////////////////////////////////////////////////////////////////////////////////////// + CMPluginBase::CMPluginBase(const char *moduleName) : m_szModuleName(moduleName) { - ::RegisterModule(this); + if (m_hInst != nullptr) + pluginListAddr.insert(this); } CMPluginBase::~CMPluginBase() @@ -37,7 +82,7 @@ CMPluginBase::~CMPluginBase() m_hLogger = nullptr; } - ::UnregisterModule(this); + pluginListAddr.remove(this); } void CMPluginBase::tryOpenLog() diff --git a/src/mir_app/src/auth.cpp b/src/mir_app/src/auth.cpp index dacbbe24ee..2a13dfc960 100644 --- a/src/mir_app/src/auth.cpp +++ b/src/mir_app/src/auth.cpp @@ -356,7 +356,7 @@ int LoadSendRecvAuthModule(void) CreateServiceFunction(MS_AUTH_SHOWADDED, ShowAddedWindow); Miranda_WaitOnHandle(LaunchAuth); - Skin_AddSound("AuthRequest", LPGENW("Alerts"), LPGENW("Authorization request")); - Skin_AddSound("AddedEvent", LPGENW("Alerts"), LPGENW("Added event")); + g_plugin.addSound("AuthRequest", LPGENW("Alerts"), LPGENW("Authorization request")); + g_plugin.addSound("AddedEvent", LPGENW("Alerts"), LPGENW("Added event")); return 0; } diff --git a/src/mir_app/src/chat_opts.cpp b/src/mir_app/src/chat_opts.cpp index 2282f53374..b532848027 100644 --- a/src/mir_app/src/chat_opts.cpp +++ b/src/mir_app/src/chat_opts.cpp @@ -324,17 +324,17 @@ int OptionsInit(void) g_Settings->iWidth = db_get_dw(0, CHAT_MODULE, "roomwidth", -1);
g_Settings->iHeight = db_get_dw(0, CHAT_MODULE, "roomheight", -1);
- Skin_AddSound("ChatMessage", LPGENW("Group chats"), LPGENW("Incoming message"));
- Skin_AddSound("ChatHighlight", LPGENW("Group chats"), LPGENW("Message is highlighted"));
- Skin_AddSound("ChatAction", LPGENW("Group chats"), LPGENW("User has performed an action"));
- Skin_AddSound("ChatJoin", LPGENW("Group chats"), LPGENW("User has joined"));
- Skin_AddSound("ChatPart", LPGENW("Group chats"), LPGENW("User has left"));
- Skin_AddSound("ChatKick", LPGENW("Group chats"), LPGENW("User has kicked some other user"));
- Skin_AddSound("ChatMode", LPGENW("Group chats"), LPGENW("User's status was changed"));
- Skin_AddSound("ChatNick", LPGENW("Group chats"), LPGENW("User has changed name"));
- Skin_AddSound("ChatNotice", LPGENW("Group chats"), LPGENW("User has sent a notice"));
- Skin_AddSound("ChatQuit", LPGENW("Group chats"), LPGENW("User has disconnected"));
- Skin_AddSound("ChatTopic", LPGENW("Group chats"), LPGENW("The topic has been changed"));
+ g_plugin.addSound("ChatMessage", LPGENW("Group chats"), LPGENW("Incoming message"));
+ g_plugin.addSound("ChatHighlight", LPGENW("Group chats"), LPGENW("Message is highlighted"));
+ g_plugin.addSound("ChatAction", LPGENW("Group chats"), LPGENW("User has performed an action"));
+ g_plugin.addSound("ChatJoin", LPGENW("Group chats"), LPGENW("User has joined"));
+ g_plugin.addSound("ChatPart", LPGENW("Group chats"), LPGENW("User has left"));
+ g_plugin.addSound("ChatKick", LPGENW("Group chats"), LPGENW("User has kicked some other user"));
+ g_plugin.addSound("ChatMode", LPGENW("Group chats"), LPGENW("User's status was changed"));
+ g_plugin.addSound("ChatNick", LPGENW("Group chats"), LPGENW("User has changed name"));
+ g_plugin.addSound("ChatNotice", LPGENW("Group chats"), LPGENW("User has sent a notice"));
+ g_plugin.addSound("ChatQuit", LPGENW("Group chats"), LPGENW("User has disconnected"));
+ g_plugin.addSound("ChatTopic", LPGENW("Group chats"), LPGENW("The topic has been changed"));
return 0;
}
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index e6e2e8f009..51440ad771 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -437,7 +437,6 @@ Hotkey_Unsubclass @457 Hotkey_Check @458
?SetStatusText@CSrmmBaseDialog@@UAEXPB_WPAUHICON__@@@Z @459 NONAME
Srmm_SetStatusText @460
-Skin_AddSound @461
Skin_PlaySound @462
Skin_PlaySoundFile @463
Clist_SetStatusMode @464
@@ -593,3 +592,7 @@ Contact_GetStatus @609 ?getMStringW@PROTO_INTERFACE@@QAE?AV?$CMStringT@_WV?$ChTraitsCRT@_W@@@@PBD@Z @620 NONAME
??0PROTOACCOUNT@@QAE@PBD@Z @621 NONAME
??1PROTOACCOUNT@@QAE@XZ @622 NONAME
+?addSound@CMPluginBase@@QAEHPBDPB_W11@Z @623 NONAME
+GetPluginByLangId @624
+GetInstByAddress @625
+GetPluginByInstance @626
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index dc486e6845..2073ce5374 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -437,7 +437,6 @@ Hotkey_Unsubclass @457 Hotkey_Check @458
?SetStatusText@CSrmmBaseDialog@@UEAAXPEB_WPEAUHICON__@@@Z @459 NONAME
Srmm_SetStatusText @460
-Skin_AddSound @461
Skin_PlaySound @462
Skin_PlaySoundFile @463
Clist_SetStatusMode @464
@@ -593,3 +592,7 @@ Contact_GetStatus @609 ?getMStringW@PROTO_INTERFACE@@QEAA?AV?$CMStringT@_WV?$ChTraitsCRT@_W@@@@PEBD@Z @620 NONAME
??0PROTOACCOUNT@@QEAA@PEBD@Z @621 NONAME
??1PROTOACCOUNT@@QEAA@XZ @622 NONAME
+?addSound@CMPluginBase@@QEAAHPEBDPEB_W11@Z @623 NONAME
+GetPluginByLangId @624
+GetInstByAddress @625
+GetPluginByInstance @626
diff --git a/src/mir_app/src/miranda.h b/src/mir_app/src/miranda.h index 718474091c..786b744f3d 100644 --- a/src/mir_app/src/miranda.h +++ b/src/mir_app/src/miranda.h @@ -188,6 +188,8 @@ INT_PTR stubChainRecv(WPARAM, LPARAM); /**** utils.cpp ************************************************************************/
+void RegisterModule(CMPluginBase*);
+
void HotkeyToName(wchar_t *buf, int size, BYTE shift, BYTE key);
WORD GetHotkeyValue(INT_PTR idHotkey);
diff --git a/src/mir_app/src/sounds.cpp b/src/mir_app/src/sounds.cpp index bc359b8ca5..198dd3cb95 100644 --- a/src/mir_app/src/sounds.cpp +++ b/src/mir_app/src/sounds.cpp @@ -59,7 +59,7 @@ MIR_APP_DLL(void) KillModuleSounds(int _hLang) static HANDLE hPlayEvent = nullptr;
-MIR_APP_DLL(int) Skin_AddSound(const char *pszName, const wchar_t *pwszSection, const wchar_t *pwszDescription, const wchar_t *pwszDefaultFile, int _hLang)
+int CMPluginBase::addSound(const char *pszName, const wchar_t *pwszSection, const wchar_t *pwszDescription, const wchar_t *pwszDefaultFile)
{
if (pszName == nullptr || pwszDescription == nullptr)
return 1;
@@ -67,7 +67,7 @@ MIR_APP_DLL(int) Skin_AddSound(const char *pszName, const wchar_t *pwszSection, SoundItem *item = new SoundItem; // due to OBJLIST
item->name = mir_strdup(pszName);
item->ptszTempFile = nullptr;
- item->hLangpack = _hLang;
+ item->hLangpack = m_hLang;
arSounds.insert(item);
item->pwszDescription = mir_wstrdup(pwszDescription);
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index 3940104584..eecbb7c04d 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -19,7 +19,6 @@ CreateServiceFunctionParam @18 DestroyHookableEvent @19
DestroyServiceFunction @20
GetExceptionFilter @21
-GetInstByAddress @22
HookEvent @23
HookEventMessage @24
HookEventObj @25
@@ -52,7 +51,6 @@ PathToAbsolute @51 PathToAbsoluteW @52
PathToRelative @53
PathToRelativeW @54
-RegisterModule @55
ReloadLangpack @56
ServiceExists @57
SetExceptionFilter @58
@@ -66,7 +64,6 @@ TranslateMenu_LP @65 TranslateW_LP @66
Ucs2toUtf8Len @67
UnhookEvent @68
-UnregisterModule @69
Utf8Decode @70
Utf8DecodeCP @71
Utf8DecodeW @72
@@ -1068,4 +1065,3 @@ IsTerminalDisconnected @1245 CallObjectEventHook @1259
?db_get_sm@@YG?AV?$CMStringT@DV?$ChTraitsCRT@D@@@@IPBD0@Z @1260 NONAME
?db_get_wsm@@YG?AV?$CMStringT@_WV?$ChTraitsCRT@_W@@@@IPBD0@Z @1261 NONAME
-GetPluginByInstance @1262
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index 2b6d5d926c..c0ebe31ddb 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -19,7 +19,6 @@ CreateServiceFunctionParam @18 DestroyHookableEvent @19
DestroyServiceFunction @20
GetExceptionFilter @21
-GetInstByAddress @22
HookEvent @23
HookEventMessage @24
HookEventObj @25
@@ -52,7 +51,6 @@ PathToAbsolute @51 PathToAbsoluteW @52
PathToRelative @53
PathToRelativeW @54
-RegisterModule @55
ReloadLangpack @56
ServiceExists @57
SetExceptionFilter @58
@@ -66,7 +64,6 @@ TranslateMenu_LP @65 TranslateW_LP @66
Ucs2toUtf8Len @67
UnhookEvent @68
-UnregisterModule @69
Utf8Decode @70
Utf8DecodeCP @71
Utf8DecodeW @72
@@ -1068,4 +1065,3 @@ IsTerminalDisconnected @1245 CallObjectEventHook @1259
?db_get_sm@@YA?AV?$CMStringT@DV?$ChTraitsCRT@D@@@@IPEBD0@Z @1260 NONAME
?db_get_wsm@@YA?AV?$CMStringT@_WV?$ChTraitsCRT@_W@@@@IPEBD0@Z @1261 NONAME
-GetPluginByInstance @1262
diff --git a/src/mir_core/src/miranda.cpp b/src/mir_core/src/miranda.cpp index e4f0b50fe8..80d28cf277 100644 --- a/src/mir_core/src/miranda.cpp +++ b/src/mir_core/src/miranda.cpp @@ -40,6 +40,9 @@ void InitMetaContacts(); void InitTimeZones();
void InitWinver();
+static int _hLang = 0;
+int &hLangpack(_hLang);
+
HINSTANCE g_hInst = nullptr;
HCURSOR g_hCursorNS, g_hCursorWE;
diff --git a/src/mir_core/src/modules.cpp b/src/mir_core/src/modules.cpp index 6af89cbab2..921de193a0 100644 --- a/src/mir_core/src/modules.cpp +++ b/src/mir_core/src/modules.cpp @@ -695,55 +695,6 @@ static void DestroyServices() /////////////////////////////////////////////////////////////////////////////// -struct CMPlugin : public CMPluginBase -{ - CMPlugin() : - CMPluginBase(nullptr) - {} -} g_plugin; - -int &hLangpack(g_plugin.m_hLang); - -LIST<CMPluginBase> pluginListAddr(10, HandleKeySortT); - -MIR_CORE_DLL(void) RegisterModule(CMPluginBase *pPlugin) -{ - if (pPlugin->getInst() != nullptr) - pluginListAddr.insert(pPlugin); -} - -MIR_CORE_DLL(void) UnregisterModule(CMPluginBase *pPlugin) -{ - pluginListAddr.remove(pPlugin); -} - -MIR_CORE_DLL(HINSTANCE) GetInstByAddress(void* codePtr) -{ - if (pluginListAddr.getCount() == 0) - return nullptr; - - int idx; - List_GetIndex((SortedList*)&pluginListAddr, (CMPluginBase*)&codePtr, &idx); - if (idx > 0) - idx--; - - HINSTANCE result = pluginListAddr[idx]->getInst(); - if (result < g_hInst && codePtr > g_hInst) - return g_hInst; - if (idx == 0 && codePtr < (void*)result) - return nullptr; - - return result; -} - -MIR_CORE_DLL(CMPluginBase&) GetPluginByInstance(HINSTANCE hInst) -{ - CMPluginBase *pPlugin = pluginListAddr.find((CMPluginBase*)&hInst); - return (pPlugin == nullptr) ? g_plugin : *pPlugin; -} - -/////////////////////////////////////////////////////////////////////////////// - int InitialiseModularEngine(void) { mainThreadId = GetCurrentThreadId(); |