OSDN Git Service

FormatPatch Finished
[tortoisegit/TortoiseGitJp.git] / src / Utils / SoundUtils.cpp
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2006 - Stefan Kueng\r
4 \r
5 // This program is free software; you can redistribute it and/or\r
6 // modify it under the terms of the GNU General Public License\r
7 // as published by the Free Software Foundation; either version 2\r
8 // of the License, or (at your option) any later version.\r
9 \r
10 // This program is distributed in the hope that it will be useful,\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 // GNU General Public License for more details.\r
14 \r
15 // You should have received a copy of the GNU General Public License\r
16 // along with this program; if not, write to the Free Software Foundation,\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
18 //\r
19 #include "StdAfx.h"\r
20 #include "registry.h"\r
21 #include "resource.h"\r
22 #include "AppUtils.h"\r
23 #include "PathUtils.h"\r
24 #include ".\soundutils.h"\r
25 \r
26 #pragma comment(lib, "Winmm")\r
27 \r
28 CSoundUtils::CSoundUtils(void)\r
29 {\r
30 }\r
31 \r
32 CSoundUtils::~CSoundUtils(void)\r
33 {\r
34 }\r
35 \r
36 void CSoundUtils::RegisterTSVNSounds()\r
37 {\r
38         // create the event labels\r
39         CRegString eventlabelerr = CRegString(_T("AppEvents\\EventLabels\\TSVN_Error\\"));\r
40         eventlabelerr = CString(MAKEINTRESOURCE(IDS_ERR_ERROR));\r
41         CRegString eventlabelwarn = CRegString(_T("AppEvents\\EventLabels\\TSVN_Warning\\"));\r
42         eventlabelwarn = CString(MAKEINTRESOURCE(IDS_WARN_WARNING));\r
43         CRegString eventlabelnote = CRegString(_T("AppEvents\\EventLabels\\TSVN_Notification\\"));\r
44         eventlabelnote = CString(MAKEINTRESOURCE(IDS_WARN_NOTE));\r
45         \r
46         CRegString appscheme = CRegString(_T("AppEvents\\Schemes\\Apps\\TortoiseProc\\"));\r
47         appscheme = _T("TortoiseSVN");\r
48 \r
49         CString apppath = CPathUtils::GetAppDirectory();\r
50         \r
51         CRegistryKey schemenamekey = CRegistryKey(_T("AppEvents\\Schemes\\Names"));\r
52         CStringList schemenames;\r
53         schemenamekey.getSubKeys(schemenames);\r
54         // if the sound scheme has been modified but not save under a different name,\r
55         // the name of the sound scheme is ".current" and not under the names list.\r
56         // so add the .current scheme to the list too\r
57         schemenames.AddHead(_T(".current"));\r
58         POSITION pos;\r
59         for (pos = schemenames.GetHeadPosition(); pos != NULL;)\r
60         {\r
61                 CString name = schemenames.GetNext(pos);\r
62                 if ((name.CompareNoCase(_T(".none"))!=0)&&(name.CompareNoCase(_T(".nosound"))!=0))\r
63                 {\r
64                         CString errorkey = _T("AppEvents\\Schemes\\Apps\\TortoiseProc\\TSVN_Error\\") + name + _T("\\");\r
65                         CRegString errorkeyval = CRegString(errorkey);\r
66                         if (((CString)(errorkeyval)).IsEmpty())\r
67                         {\r
68                                 errorkeyval = apppath + _T("TortoiseSVN_Error.wav");\r
69                         }\r
70                         CString warnkey = _T("AppEvents\\Schemes\\Apps\\TortoiseProc\\TSVN_Warning\\") + name + _T("\\");\r
71                         CRegString warnkeyval = CRegString(warnkey);\r
72                         if (((CString)(warnkeyval)).IsEmpty())\r
73                         {\r
74                                 warnkeyval = apppath + _T("TortoiseSVN_Warning.wav");\r
75                         }\r
76                         CString notificationkey = _T("AppEvents\\Schemes\\Apps\\TortoiseProc\\TSVN_Notification\\") + name + _T("\\");\r
77                         CRegString notificationkeyval = CRegString(notificationkey);\r
78                         if (((CString)(notificationkeyval)).IsEmpty())\r
79                         {\r
80                                 notificationkeyval = apppath + _T("TortoiseSVN_Notification.wav");\r
81                         }\r
82                 }               \r
83         }\r
84 }\r
85 \r
86 void CSoundUtils::PlayTSVNWarning()\r
87 {\r
88         PlaySound(_T("TSVN_Warning"), NULL, SND_APPLICATION | SND_ASYNC | SND_NODEFAULT);\r
89 }\r
90 \r
91 void CSoundUtils::PlayTSVNError()\r
92 {\r
93         PlaySound(_T("TSVN_Error"), NULL, SND_APPLICATION | SND_ASYNC | SND_NODEFAULT);\r
94 }\r
95 \r
96 void CSoundUtils::PlayTSVNNotification()\r
97 {\r
98         PlaySound(_T("TSVN_Notification"), NULL, SND_APPLICATION | SND_ASYNC | SND_NODEFAULT);\r
99 }