From 8b4ca50acec418a7b16241b022f4e4b98ee971d3 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 4 Apr 2013 18:25:38 +0000 Subject: MS_SKIN_PLAYSOUNDFILE: extension of MS_SKIN_PLAYSOUND that plays almost any file git-svn-id: http://svn.miranda-ng.org/main/trunk@4304 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- include/m_skin.h | 12 +++++++++++- src/modules/skin/sounds.cpp | 29 +++++++++++++++++++++-------- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/include/m_skin.h b/include/m_skin.h index 0da463463d..a57d79f238 100644 --- a/include/m_skin.h +++ b/include/m_skin.h @@ -188,7 +188,7 @@ __forceinline INT_PTR Skin_AddSound(SKINSOUNDDESCEX *ssd) return CallService("Skin/Sounds/AddNew", hLangpack, (LPARAM)ssd); } -//play a named sound event +//plays a named sound event //wParam = 0 //lParam = (LPARAM)(const char*)pszName //pszName should have been added with Skin/Sounds/AddNew, but if not the @@ -200,6 +200,16 @@ __forceinline INT_PTR SkinPlaySound(const char *name) return CallService(MS_SKIN_PLAYSOUND, 0, (LPARAM)name); } +//plays any sound file +//wParam = 0 +//lParam = (LPARAM)(const TCHAR*)ptszFileName +#define MS_SKIN_PLAYSOUNDFILE "Skin/Sounds/PlayFile" + +__forceinline INT_PTR SkinPlaySoundFile(const TCHAR *ptszFileName) +{ + return CallService(MS_SKIN_PLAYSOUNDFILE, 0, (LPARAM)ptszFileName); +} + //sent when the icons DLL has been changed in the options dialog, and everyone //should re-make their image lists //wParam = lParam = 0 diff --git a/src/modules/skin/sounds.cpp b/src/modules/skin/sounds.cpp index 8133a7e5ef..80a7e5ff1c 100644 --- a/src/modules/skin/sounds.cpp +++ b/src/modules/skin/sounds.cpp @@ -112,6 +112,18 @@ static int SkinPlaySoundDefault(WPARAM wParam, LPARAM lParam) return 0; } +static INT_PTR ServiceSkinPlaySoundFile(WPARAM, LPARAM lParam) +{ + TCHAR *ptszFileName = (TCHAR*)lParam; + if (ptszFileName == NULL) + return 1; + + TCHAR tszFull[MAX_PATH]; + PathToAbsoluteT(ptszFileName, tszFull); + NotifyEventHooks(hPlayEvent, 0, (LPARAM)tszFull); + return 0; +} + static INT_PTR ServiceSkinPlaySound(WPARAM, LPARAM lParam) { char* pszSoundName = (char*)lParam; @@ -123,14 +135,14 @@ static INT_PTR ServiceSkinPlaySound(WPARAM, LPARAM lParam) if (idx == -1) return 1; - if ( db_get_b(NULL, "SkinSoundsOff", pszSoundName, 0) == 0) { - DBVARIANT dbv; - if ( DBGetContactSettingTString(NULL, "SkinSounds", pszSoundName, &dbv) == 0) { - TCHAR szFull[MAX_PATH]; - PathToAbsoluteT(dbv.ptszVal, szFull); - NotifyEventHooks(hPlayEvent, 0, (LPARAM)szFull); - db_free(&dbv); - } + if ( db_get_b(NULL, "SkinSoundsOff", pszSoundName, 0)) + return 1; + + DBVARIANT dbv; + if ( DBGetContactSettingTString(NULL, "SkinSounds", pszSoundName, &dbv) == 0) { + ServiceSkinPlaySoundFile(0, (LPARAM)dbv.ptszVal); + db_free(&dbv); + return 0; } return 1; } @@ -446,6 +458,7 @@ int LoadSkinSounds(void) 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); -- cgit v1.2.3