/* Miranda IM: the free IM client for Microsoft* Windows* Copyright 2000-2006 Miranda ICQ/IM project, all portions of this codebase are copyrighted to the people listed in contributors.txt. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "commonheaders.h" struct SoundItem { char* name; TCHAR* section; TCHAR* description; char* tempFile; }; static struct SoundItem *soundList = NULL; static int soundCount; static HANDLE hPlayEvent = NULL; static int ServiceSkinAddNewSound(WPARAM wParam,LPARAM lParam) { struct SoundItem* item; SKINSOUNDDESCEX *ssd=(SKINSOUNDDESCEX*)lParam; if (ssd->cbSize!=sizeof(SKINSOUNDDESC) && ssd->cbSize!=sizeof(SKINSOUNDDESCEX)) return 0; soundList=(struct SoundItem*)mir_realloc(soundList,sizeof(struct SoundItem)*(soundCount+1)); item = &soundList[soundCount++]; item->name = mir_strdup( ssd->pszName ); item->description = LangPackPcharToTchar( ssd->pszDescription ); item->section = LangPackPcharToTchar( ssd->cbSize==sizeof(SKINSOUNDDESCEX) ? ssd->pszSection : "Other" ); item->tempFile = NULL; if ( ssd->pszDefaultFile ) { DBVARIANT dbv; if ( DBGetContactSetting(NULL, "SkinSounds", item->name, &dbv)) DBWriteContactSettingString(NULL, "SkinSounds", item->name, ssd->pszDefaultFile); else DBFreeVariant(&dbv); } return 0; } static int SkinPlaySoundDefault(WPARAM wParam, LPARAM lParam) { char * pszFile = (char *) lParam; if ( pszFile && (DBGetContactSettingByte(NULL,"Skin","UseSound",1) || (int)wParam==1)) { PlaySoundA(pszFile, NULL, SND_ASYNC | SND_FILENAME | SND_NOWAIT); } return 0; } static int ServiceSkinPlaySound(WPARAM wParam, LPARAM lParam) { char * pszSoundName = (char *)lParam; int j; for (j=0; jidFrom) { case 0: if (((LPNMHDR)lParam)->code == PSN_APPLY) { int i; for(i=0;i>12==2)) { DBCONTACTGETSETTING cgs; cgs.szModule="SkinSoundsOff"; cgs.szSetting=soundList[tvic.lParam].name; CallService(MS_DB_CONTACT_DELETESETTING,(WPARAM)(HANDLE)NULL,(LPARAM)&cgs); } else DBWriteContactSettingByte(NULL,"SkinSoundsOff",soundList[tvic.lParam].name,1); tvic.hItem=TreeView_GetNextSibling(hwndTree,tvic.hItem); } } tvi.hItem=TreeView_GetNextSibling(hwndTree,tvi.hItem); } } return TRUE; } break; case IDC_SOUNDTREE: switch(((NMHDR*)lParam)->code) { case TVN_SELCHANGEDA: { NMTREEVIEW *pnmtv = (NMTREEVIEW*)lParam; TVITEM tvi = pnmtv->itemNew; if (tvi.lParam==-1) { SendMessage(hwndDlg, DM_HIDEPANE, 0, 0); } else { TCHAR buf[256]; DBVARIANT dbv; mir_sntprintf(buf, SIZEOF(buf), _T("%s: %s"), soundList[tvi.lParam].section, soundList[tvi.lParam].description); SetDlgItemText(hwndDlg, IDC_NAMEVAL, buf); if (soundList[tvi.lParam].tempFile) SetDlgItemTextA(hwndDlg, IDC_LOCATION, soundList[tvi.lParam].tempFile); else if(!DBGetContactSetting(NULL,"SkinSounds",soundList[tvi.lParam].name,&dbv)) { SetDlgItemTextA(hwndDlg, IDC_LOCATION, dbv.pszVal); DBFreeVariant(&dbv); } else SetDlgItemText(hwndDlg, IDC_LOCATION, TranslateT("")); SendMessage(hwndDlg, DM_SHOWPANE, 0, 0); } } break; case TVN_KEYDOWN: { NMTVKEYDOWN* ptkd = (NMTVKEYDOWN*)lParam; TVHITTESTINFO hti; if (ptkd) { if (ptkd->wVKey == 0x0020) { hti.pt.x=(short)LOWORD(GetMessagePos()); hti.pt.y=(short)HIWORD(GetMessagePos()); ScreenToClient(((LPNMHDR)lParam)->hwndFrom,&hti.pt); if(TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom,&hti)) { if (hti.flags&TVHT_ONITEM) { if (TreeView_GetParent(hwndTree, hti.hItem)!=TreeView_GetRoot(hwndTree)) { // the stupid checkbox gets enabled here. } else { SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } } } } } } break; case NM_CLICK: { TVHITTESTINFO hti; hti.pt.x=(short)LOWORD(GetMessagePos()); hti.pt.y=(short)HIWORD(GetMessagePos()); ScreenToClient(((LPNMHDR)lParam)->hwndFrom,&hti.pt); if(TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom,&hti)) { if (hti.flags&TVHT_ONITEM) { if(hti.flags&TVHT_ONITEMSTATEICON) { if (TreeView_GetParent(hwndTree, hti.hItem)!=TreeView_GetRoot(hwndTree)) SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } } } break; } } break; } break; } return FALSE; } int InitSkinSounds(void) { soundList=NULL; soundCount=0; CreateServiceFunction(MS_SKIN_ADDNEWSOUND,ServiceSkinAddNewSound); CreateServiceFunction(MS_SKIN_PLAYSOUND,ServiceSkinPlaySound); hPlayEvent=CreateHookableEvent(ME_SKIN_PLAYINGSOUND); SetHookDefaultForHookableEvent(hPlayEvent, SkinPlaySoundDefault); return 0; } void UninitSkinSounds(void) { int i; for(i=0;i