Cleanup
[TortoiseGit.git] / src / Utils / SoundUtils.cpp
blobfad1fe16a4fb9edf0be52afb74bbe3bf517def2d
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2006 - Stefan Kueng
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include "StdAfx.h"
20 #include "registry.h"
21 #include "..\TortoiseProc\resource.h"
22 #include "..\TortoiseProc\AppUtils.h"
23 #include "PathUtils.h"
24 #include ".\soundutils.h"
25 #include "mmsystem.h"
27 #pragma comment(lib, "Winmm")
29 CSoundUtils::CSoundUtils(void)
33 CSoundUtils::~CSoundUtils(void)
37 void CSoundUtils::RegisterTGitSounds()
39 // create the event labels
40 CRegString eventlabelerr = CRegString(_T("AppEvents\\EventLabels\\TGit_Error\\"));
41 eventlabelerr = CString(MAKEINTRESOURCE(IDS_ERR_ERROR));
42 CRegString eventlabelwarn = CRegString(_T("AppEvents\\EventLabels\\TGit_Warning\\"));
43 eventlabelwarn = CString(MAKEINTRESOURCE(IDS_WARN_WARNING));
44 CRegString eventlabelnote = CRegString(_T("AppEvents\\EventLabels\\TGit_Notification\\"));
45 eventlabelnote = CString(MAKEINTRESOURCE(IDS_WARN_NOTE));
47 CRegString appscheme = CRegString(_T("AppEvents\\Schemes\\Apps\\TortoiseProc\\"));
48 appscheme = _T("TortoiseGit");
50 CString apppath = CPathUtils::GetAppDirectory();
52 CRegistryKey schemenamekey = CRegistryKey(_T("AppEvents\\Schemes\\Names"));
53 CStringList schemenames;
54 schemenamekey.getSubKeys(schemenames);
55 // if the sound scheme has been modified but not save under a different name,
56 // the name of the sound scheme is ".current" and not under the names list.
57 // so add the .current scheme to the list too
58 schemenames.AddHead(_T(".current"));
59 POSITION pos;
60 for (pos = schemenames.GetHeadPosition(); pos != NULL;)
62 CString name = schemenames.GetNext(pos);
63 if ((name.CompareNoCase(_T(".none"))!=0)&&(name.CompareNoCase(_T(".nosound"))!=0))
65 CString errorkey = _T("AppEvents\\Schemes\\Apps\\TortoiseProc\\TGit_Error\\") + name + _T("\\");
66 CRegString errorkeyval = CRegString(errorkey);
67 if (((CString)(errorkeyval)).IsEmpty())
69 errorkeyval = apppath + _T("TortoiseGit_Error.wav");
71 CString warnkey = _T("AppEvents\\Schemes\\Apps\\TortoiseProc\\TGit_Warning\\") + name + _T("\\");
72 CRegString warnkeyval = CRegString(warnkey);
73 if (((CString)(warnkeyval)).IsEmpty())
75 warnkeyval = apppath + _T("TortoiseGit_Warning.wav");
77 CString notificationkey = _T("AppEvents\\Schemes\\Apps\\TortoiseProc\\TGit_Notification\\") + name + _T("\\");
78 CRegString notificationkeyval = CRegString(notificationkey);
79 if (((CString)(notificationkeyval)).IsEmpty())
81 notificationkeyval = apppath + _T("TortoiseGit_Notification.wav");
87 void CSoundUtils::PlayTGitWarning()
89 PlaySound(_T("TGit_Warning"), NULL, SND_APPLICATION | SND_ASYNC | SND_NODEFAULT);
92 void CSoundUtils::PlayTGitError()
94 PlaySound(_T("TGit_Error"), NULL, SND_APPLICATION | SND_ASYNC | SND_NODEFAULT);
97 void CSoundUtils::PlayTGitNotification()
99 PlaySound(_T("TGit_Notification"), NULL, SND_APPLICATION | SND_ASYNC | SND_NODEFAULT);