summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-05-20 00:17:30 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-05-20 00:17:30 +0300
commit7deea6cec5d2173f66d4c2dd75ca0b633b887bc7 (patch)
tree8e95a2e5a707ef578c2f070b997156fcda6f088c /src/mir_app
parent15051a110d2575c2baa9a3b358977000c876abd9 (diff)
sounds packed into CMPlugin (reduces usage of hLangpack)
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/src/CMPluginBase.cpp49
-rw-r--r--src/mir_app/src/auth.cpp4
-rw-r--r--src/mir_app/src/chat_opts.cpp22
-rw-r--r--src/mir_app/src/mir_app.def5
-rw-r--r--src/mir_app/src/mir_app64.def5
-rw-r--r--src/mir_app/src/miranda.h2
-rw-r--r--src/mir_app/src/sounds.cpp4
7 files changed, 72 insertions, 19 deletions
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);