OSDN Git Service

Using GitProcessBar to show add process!
[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 "..\TortoiseProc\resource.h"\r
22 #include "..\TortoiseProc\AppUtils.h"\r
23 #include "PathUtils.h"\r
24 #include ".\soundutils.h"\r
25 #include "mmsystem.h"\r
26 \r
27 #pragma comment(lib, "Winmm")\r
28 \r
29 CSoundUtils::CSoundUtils(void)\r
30 {\r
31 }\r
32 \r
33 CSoundUtils::~CSoundUtils(void)\r
34 {\r
35 }\r
36 \r
37 void CSoundUtils::RegisterTGitSounds()\r
38 {\r
39         // create the event labels\r
40         CRegString eventlabelerr = CRegString(_T("AppEvents\\EventLabels\\TGit_Error\\"));\r
41         eventlabelerr = CString(MAKEINTRESOURCE(IDS_ERR_ERROR));\r
42         CRegString eventlabelwarn = CRegString(_T("AppEvents\\EventLabels\\TGit_Warning\\"));\r
43         eventlabelwarn = CString(MAKEINTRESOURCE(IDS_WARN_WARNING));\r
44         CRegString eventlabelnote = CRegString(_T("AppEvents\\EventLabels\\TGit_Notification\\"));\r
45         eventlabelnote = CString(MAKEINTRESOURCE(IDS_WARN_NOTE));\r
46         \r
47         CRegString appscheme = CRegString(_T("AppEvents\\Schemes\\Apps\\TortoiseProc\\"));\r
48         appscheme = _T("TortoiseGit");\r
49 \r
50         CString apppath = CPathUtils::GetAppDirectory();\r
51         \r
52         CRegistryKey schemenamekey = CRegistryKey(_T("AppEvents\\Schemes\\Names"));\r
53         CStringList schemenames;\r
54         schemenamekey.getSubKeys(schemenames);\r
55         // if the sound scheme has been modified but not save under a different name,\r
56         // the name of the sound scheme is ".current" and not under the names list.\r
57         // so add the .current scheme to the list too\r
58         schemenames.AddHead(_T(".current"));\r
59         POSITION pos;\r
60         for (pos = schemenames.GetHeadPosition(); pos != NULL;)\r
61         {\r
62                 CString name = schemenames.GetNext(pos);\r
63                 if ((name.CompareNoCase(_T(".none"))!=0)&&(name.CompareNoCase(_T(".nosound"))!=0))\r
64                 {\r
65                         CString errorkey = _T("AppEvents\\Schemes\\Apps\\TortoiseProc\\TGit_Error\\") + name + _T("\\");\r
66                         CRegString errorkeyval = CRegString(errorkey);\r
67                         if (((CString)(errorkeyval)).IsEmpty())\r
68                         {\r
69                                 errorkeyval = apppath + _T("TortoiseGit_Error.wav");\r
70                         }\r
71                         CString warnkey = _T("AppEvents\\Schemes\\Apps\\TortoiseProc\\TGit_Warning\\") + name + _T("\\");\r
72                         CRegString warnkeyval = CRegString(warnkey);\r
73                         if (((CString)(warnkeyval)).IsEmpty())\r
74                         {\r
75                                 warnkeyval = apppath + _T("TortoiseGit_Warning.wav");\r
76                         }\r
77                         CString notificationkey = _T("AppEvents\\Schemes\\Apps\\TortoiseProc\\TGit_Notification\\") + name + _T("\\");\r
78                         CRegString notificationkeyval = CRegString(notificationkey);\r
79                         if (((CString)(notificationkeyval)).IsEmpty())\r
80                         {\r
81                                 notificationkeyval = apppath + _T("TortoiseGit_Notification.wav");\r
82                         }\r
83                 }               \r
84         }\r
85 }\r
86 \r
87 void CSoundUtils::PlayTGitWarning()\r
88 {\r
89         PlaySound(_T("TGit_Warning"), NULL, SND_APPLICATION | SND_ASYNC | SND_NODEFAULT);\r
90 }\r
91 \r
92 void CSoundUtils::PlayTGitError()\r
93 {\r
94         PlaySound(_T("TGit_Error"), NULL, SND_APPLICATION | SND_ASYNC | SND_NODEFAULT);\r
95 }\r
96 \r
97 void CSoundUtils::PlayTGitNotification()\r
98 {\r
99         PlaySound(_T("TGit_Notification"), NULL, SND_APPLICATION | SND_ASYNC | SND_NODEFAULT);\r
100 }