summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/src/button.cpp2
-rw-r--r--src/mir_app/src/chat_opts.cpp22
-rw-r--r--src/mir_app/src/chat_tools.cpp22
-rw-r--r--src/mir_app/src/mir_app.def3
-rw-r--r--src/mir_app/src/mir_app64.def3
-rw-r--r--src/mir_app/src/sounds.cpp104
6 files changed, 70 insertions, 86 deletions
diff --git a/src/mir_app/src/button.cpp b/src/mir_app/src/button.cpp
index ba0b4e8714..a39b55e5ce 100644
--- a/src/mir_app/src/button.cpp
+++ b/src/mir_app/src/button.cpp
@@ -37,7 +37,7 @@ struct TTooltips
static LIST<TTooltips> lToolTips(1, NumericKeySortT);
static mir_cs csTips;
-static BOOL bModuleInitialized = FALSE;
+static bool bModuleInitialized = false;
// Used for our own cheap TrackMouseEvent
#define BUTTON_POLLID 100
diff --git a/src/mir_app/src/chat_opts.cpp b/src/mir_app/src/chat_opts.cpp
index 1b31dae8f5..98ea06b72c 100644
--- a/src/mir_app/src/chat_opts.cpp
+++ b/src/mir_app/src/chat_opts.cpp
@@ -323,17 +323,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);
- SkinAddNewSoundEx("ChatMessage", LPGEN("Group chats"), LPGEN("Incoming message"));
- SkinAddNewSoundEx("ChatHighlight", LPGEN("Group chats"), LPGEN("Message is highlighted"));
- SkinAddNewSoundEx("ChatAction", LPGEN("Group chats"), LPGEN("User has performed an action"));
- SkinAddNewSoundEx("ChatJoin", LPGEN("Group chats"), LPGEN("User has joined"));
- SkinAddNewSoundEx("ChatPart", LPGEN("Group chats"), LPGEN("User has left"));
- SkinAddNewSoundEx("ChatKick", LPGEN("Group chats"), LPGEN("User has kicked some other user"));
- SkinAddNewSoundEx("ChatMode", LPGEN("Group chats"), LPGEN("User's status was changed"));
- SkinAddNewSoundEx("ChatNick", LPGEN("Group chats"), LPGEN("User has changed name"));
- SkinAddNewSoundEx("ChatNotice", LPGEN("Group chats"), LPGEN("User has sent a notice"));
- SkinAddNewSoundEx("ChatQuit", LPGEN("Group chats"), LPGEN("User has disconnected"));
- SkinAddNewSoundEx("ChatTopic", LPGEN("Group chats"), LPGEN("The topic has been changed"));
+ 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"));
return 0;
}
diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp
index 2b0ccdde6b..1bffbfb6a3 100644
--- a/src/mir_app/src/chat_tools.cpp
+++ b/src/mir_app/src/chat_tools.cpp
@@ -280,7 +280,7 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight
if (bHighlight) {
gce->pDest->iType |= GC_EVENT_HIGHLIGHT;
if (bInactive || !g_Settings->bSoundsFocus)
- SkinPlaySound("ChatHighlight");
+ Skin_PlaySound("ChatHighlight");
if (db_get_b(si->hContact, "CList", "Hidden", 0) != 0)
db_unset(si->hContact, "CList", "Hidden");
if (bInactive)
@@ -306,28 +306,28 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight
switch (iEvent) {
case GC_EVENT_JOIN:
if (bInactive || !g_Settings->bSoundsFocus)
- SkinPlaySound("ChatJoin");
+ Skin_PlaySound("ChatJoin");
break;
case GC_EVENT_PART:
if (bInactive || !g_Settings->bSoundsFocus)
- SkinPlaySound("ChatPart");
+ Skin_PlaySound("ChatPart");
break;
case GC_EVENT_QUIT:
if (bInactive || !g_Settings->bSoundsFocus)
- SkinPlaySound("ChatQuit");
+ Skin_PlaySound("ChatQuit");
break;
case GC_EVENT_ADDSTATUS:
case GC_EVENT_REMOVESTATUS:
if (bInactive || !g_Settings->bSoundsFocus)
- SkinPlaySound("ChatMode");
+ Skin_PlaySound("ChatMode");
break;
case GC_EVENT_KICK:
if (bInactive || !g_Settings->bSoundsFocus)
- SkinPlaySound("ChatKick");
+ Skin_PlaySound("ChatKick");
break;
case GC_EVENT_MESSAGE:
if (bInactive || !g_Settings->bSoundsFocus)
- SkinPlaySound("ChatMessage");
+ Skin_PlaySound("ChatMessage");
if (bInactive && !(si->wState & STATE_TALK)) {
si->wState |= STATE_TALK;
@@ -338,19 +338,19 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight
break;
case GC_EVENT_ACTION:
if (bInactive || !g_Settings->bSoundsFocus)
- SkinPlaySound("ChatAction");
+ Skin_PlaySound("ChatAction");
break;
case GC_EVENT_NICK:
if (bInactive || !g_Settings->bSoundsFocus)
- SkinPlaySound("ChatNick");
+ Skin_PlaySound("ChatNick");
break;
case GC_EVENT_NOTICE:
if (bInactive || !g_Settings->bSoundsFocus)
- SkinPlaySound("ChatNotice");
+ Skin_PlaySound("ChatNotice");
break;
case GC_EVENT_TOPIC:
if (bInactive || !g_Settings->bSoundsFocus)
- SkinPlaySound("ChatTopic");
+ Skin_PlaySound("ChatTopic");
break;
}
}
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index a0addf8ff5..f810bb6e0e 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -453,3 +453,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
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 963f8cd9ad..ec9a39feb2 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -453,3 +453,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
diff --git a/src/mir_app/src/sounds.cpp b/src/mir_app/src/sounds.cpp
index 9775a42965..a6a964119f 100644
--- a/src/mir_app/src/sounds.cpp
+++ b/src/mir_app/src/sounds.cpp
@@ -53,7 +53,7 @@ static int CompareSounds(const SoundItem* p1, const SoundItem* p2)
static OBJLIST<SoundItem> arSounds(10, CompareSounds);
-///////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
MIR_APP_DLL(void) KillModuleSounds(int _hLang)
{
@@ -66,66 +66,34 @@ MIR_APP_DLL(void) KillModuleSounds(int _hLang)
}
}
-///////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
-HTREEITEM FindNamedTreeItemAtRoot(HWND hwndTree, const wchar_t* name)
-{
- wchar_t str[128];
- TVITEM tvi;
- tvi.mask = TVIF_TEXT;
- tvi.pszText = str;
- tvi.cchTextMax = _countof(str);
- tvi.hItem = TreeView_GetRoot(hwndTree);
- while (tvi.hItem != nullptr) {
- SendMessage(hwndTree, TVM_GETITEM, 0, (LPARAM)&tvi);
- if (!mir_wstrcmpi(str, name))
- return tvi.hItem;
-
- tvi.hItem = TreeView_GetNextSibling(hwndTree, tvi.hItem);
- }
- return nullptr;
-}
-
-static BOOL bModuleInitialized = FALSE;
static HANDLE hPlayEvent = nullptr;
-static INT_PTR ServiceSkinAddNewSound(WPARAM wParam, LPARAM lParam)
+MIR_APP_DLL(int) Skin_AddSound(const char *pszName, const wchar_t *pwszSection, const wchar_t *pwszDescription, const wchar_t *pwszDefaultFile, int _hLang)
{
- SKINSOUNDDESCEX *ssd = (SKINSOUNDDESCEX*)lParam;
- if (ssd->cbSize != sizeof(SKINSOUNDDESCEX) || ssd->pszName == nullptr || ssd->pszDescription == nullptr)
+ if (pszName == nullptr || pwszDescription == nullptr)
return 1;
SoundItem *item = new SoundItem; // due to OBJLIST
- item->name = mir_strdup(ssd->pszName);
+ item->name = mir_strdup(pszName);
item->ptszTempFile = nullptr;
- item->hLangpack = (int)wParam;
+ item->hLangpack = _hLang;
arSounds.insert(item);
- wchar_t *pwszDefaultFile;
- if (ssd->dwFlags & SSDF_UNICODE) {
- item->pwszDescription = mir_wstrdup(ssd->pwszDescription);
- item->pwszSection = mir_wstrdup((ssd->pszSection != nullptr) ? ssd->pwszSection : L"Other");
- pwszDefaultFile = mir_wstrdup(ssd->pwszDefaultFile);
- }
- else {
- item->pwszDescription = mir_a2u(ssd->pszDescription);
- item->pwszSection = mir_a2u((ssd->pszSection != nullptr) ? ssd->pszSection : "Other");
- pwszDefaultFile = mir_a2u(ssd->pszDefaultFile);
- }
+ item->pwszDescription = mir_wstrdup(pwszDescription);
+ item->pwszSection = mir_wstrdup((pwszSection != nullptr) ? pwszSection : L"Other");
if (pwszDefaultFile) {
- DBVARIANT dbv;
- if (db_get_s(0, "SkinSounds", item->name, &dbv))
+ ptrW wszSavedValue(db_get_wsa(0, "SkinSounds", item->name));
+ if (wszSavedValue == nullptr)
db_set_ws(0, "SkinSounds", item->name, pwszDefaultFile);
- else
- db_free(&dbv);
- mir_free(pwszDefaultFile);
}
return 0;
}
-static int SkinPlaySoundDefault(WPARAM wParam, LPARAM lParam)
+static int Skin_PlaySoundDefault(WPARAM wParam, LPARAM lParam)
{
wchar_t *pszFile = (wchar_t*) lParam;
if (pszFile && (db_get_b(0, "Skin", "UseSound", 0) || (int)wParam == 1))
@@ -134,25 +102,23 @@ static int SkinPlaySoundDefault(WPARAM wParam, LPARAM lParam)
return 0;
}
-static INT_PTR ServiceSkinPlaySoundFile(WPARAM, LPARAM lParam)
+MIR_APP_DLL(int) Skin_PlaySoundFile(const wchar_t *pwszFileName)
{
- wchar_t *ptszFileName = (wchar_t*)lParam;
- if (ptszFileName == nullptr)
+ if (pwszFileName == nullptr)
return 1;
wchar_t tszFull[MAX_PATH];
- PathToAbsoluteW(ptszFileName, tszFull);
+ PathToAbsoluteW(pwszFileName, tszFull);
NotifyEventHooks(hPlayEvent, 0, (LPARAM)tszFull);
return 0;
}
-static INT_PTR ServiceSkinPlaySound(WPARAM, LPARAM lParam)
+MIR_APP_DLL(int) Skin_PlaySound(const char *pszSoundName)
{
- char *pszSoundName = (char*)lParam;
if (pszSoundName == nullptr)
return 1;
- SoundItem tmp = { pszSoundName };
+ SoundItem tmp = { (char*)pszSoundName };
int idx = arSounds.getIndex(&tmp);
if (idx == -1)
return 1;
@@ -160,13 +126,12 @@ static INT_PTR ServiceSkinPlaySound(WPARAM, LPARAM lParam)
if (db_get_b(0, "SkinSoundsOff", pszSoundName, 0))
return 1;
- DBVARIANT dbv;
- if (db_get_ws(0, "SkinSounds", pszSoundName, &dbv) == 0) {
- ServiceSkinPlaySoundFile(0, (LPARAM)dbv.ptszVal);
- db_free(&dbv);
- return 0;
- }
- return 1;
+ ptrW wszFilePath(db_get_wsa(0, "SkinSounds", pszSoundName));
+ if (wszFilePath == nullptr)
+ return 1;
+
+ Skin_PlaySoundFile(wszFilePath);
+ return 0;
}
#define DM_REBUILD_STREE (WM_USER+1)
@@ -174,6 +139,24 @@ static INT_PTR ServiceSkinPlaySound(WPARAM, LPARAM lParam)
#define DM_SHOWPANE (WM_USER+3)
#define DM_CHECKENABLED (WM_USER+4)
+static HTREEITEM FindNamedTreeItemAtRoot(HWND hwndTree, const wchar_t* name)
+{
+ wchar_t str[128];
+ TVITEM tvi;
+ tvi.mask = TVIF_TEXT;
+ tvi.pszText = str;
+ tvi.cchTextMax = _countof(str);
+ tvi.hItem = TreeView_GetRoot(hwndTree);
+ while (tvi.hItem != nullptr) {
+ SendMessage(hwndTree, TVM_GETITEM, 0, (LPARAM)&tvi);
+ if (!mir_wstrcmpi(str, name))
+ return tvi.hItem;
+
+ tvi.hItem = TreeView_GetNextSibling(hwndTree, tvi.hItem);
+ }
+ return nullptr;
+}
+
INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
static HWND hwndTree = nullptr;
@@ -474,14 +457,9 @@ static int SkinSystemModulesLoaded(WPARAM, LPARAM)
int LoadSkinSounds(void)
{
- bModuleInitialized = TRUE;
-
- CreateServiceFunction("Skin/Sounds/AddNew", ServiceSkinAddNewSound);
- CreateServiceFunction(MS_SKIN_PLAYSOUND, ServiceSkinPlaySound);
- CreateServiceFunction(MS_SKIN_PLAYSOUNDFILE, ServiceSkinPlaySoundFile);
HookEvent(ME_SYSTEM_MODULESLOADED, SkinSystemModulesLoaded);
hPlayEvent = CreateHookableEvent(ME_SKIN_PLAYINGSOUND);
- SetHookDefaultForHookableEvent(hPlayEvent, SkinPlaySoundDefault);
+ SetHookDefaultForHookableEvent(hPlayEvent, Skin_PlaySoundDefault);
return 0;
}