1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009,2013 - TortoiseGit
4 // Copyright (C) 2003-2006 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "..\TortoiseProc\resource.h"
23 #include "..\TortoiseProc\AppUtils.h"
24 #include "PathUtils.h"
25 #include "SoundUtils.h"
28 #pragma comment(lib, "Winmm")
30 CSoundUtils::CSoundUtils(void)
34 CSoundUtils::~CSoundUtils(void)
38 void CSoundUtils::RegisterTGitSounds()
40 // create the event labels
41 CRegString eventlabelerr
= CRegString(_T("AppEvents\\EventLabels\\TGit_Error\\"));
42 eventlabelerr
= CString(MAKEINTRESOURCE(IDS_ERR_ERROR
));
43 CRegString eventlabelwarn
= CRegString(_T("AppEvents\\EventLabels\\TGit_Warning\\"));
44 eventlabelwarn
= CString(MAKEINTRESOURCE(IDS_WARN_WARNING
));
45 CRegString eventlabelnote
= CRegString(_T("AppEvents\\EventLabels\\TGit_Notification\\"));
46 eventlabelnote
= CString(MAKEINTRESOURCE(IDS_WARN_NOTE
));
48 CRegString appscheme
= CRegString(_T("AppEvents\\Schemes\\Apps\\TortoiseGitProc\\"));
49 appscheme
= _T("TortoiseGit");
51 CString apppath
= CPathUtils::GetAppDirectory();
53 CRegistryKey schemenamekey
= CRegistryKey(_T("AppEvents\\Schemes\\Names"));
54 CStringList schemenames
;
55 schemenamekey
.getSubKeys(schemenames
);
56 // if the sound scheme has been modified but not save under a different name,
57 // the name of the sound scheme is ".current" and not under the names list.
58 // so add the .current scheme to the list too
59 schemenames
.AddHead(_T(".current"));
61 for (pos
= schemenames
.GetHeadPosition(); pos
!= NULL
;)
63 CString name
= schemenames
.GetNext(pos
);
64 if ((name
.CompareNoCase(_T(".none"))!=0)&&(name
.CompareNoCase(_T(".nosound"))!=0))
66 CString errorkey
= _T("AppEvents\\Schemes\\Apps\\TortoiseGitProc\\TGit_Error\\") + name
+ _T("\\");
67 CRegString errorkeyval
= CRegString(errorkey
);
68 if (((CString
)(errorkeyval
)).IsEmpty())
70 errorkeyval
= apppath
+ _T("TortoiseGit_Error.wav");
72 CString warnkey
= _T("AppEvents\\Schemes\\Apps\\TortoiseGitProc\\TGit_Warning\\") + name
+ _T("\\");
73 CRegString warnkeyval
= CRegString(warnkey
);
74 if (((CString
)(warnkeyval
)).IsEmpty())
76 warnkeyval
= apppath
+ _T("TortoiseGit_Warning.wav");
78 CString notificationkey
= _T("AppEvents\\Schemes\\Apps\\TortoiseGitProc\\TGit_Notification\\") + name
+ _T("\\");
79 CRegString notificationkeyval
= CRegString(notificationkey
);
80 if (((CString
)(notificationkeyval
)).IsEmpty())
82 notificationkeyval
= apppath
+ _T("TortoiseGit_Notification.wav");
88 void CSoundUtils::PlayTGitWarning()
90 PlaySound(_T("TGit_Warning"), NULL
, SND_APPLICATION
| SND_ASYNC
| SND_NODEFAULT
);
93 void CSoundUtils::PlayTGitError()
95 PlaySound(_T("TGit_Error"), NULL
, SND_APPLICATION
| SND_ASYNC
| SND_NODEFAULT
);
98 void CSoundUtils::PlayTGitNotification()
100 PlaySound(_T("TGit_Notification"), NULL
, SND_APPLICATION
| SND_ASYNC
| SND_NODEFAULT
);