summaryrefslogtreecommitdiff
path: root/plugins/XSoundNotify/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-08-18 11:49:54 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-08-18 11:49:54 +0000
commit878d72910cccf4f84c7cb45bb4c11134920f3166 (patch)
tree251fba89632c389309ff9b2451850aa949efb8d0 /plugins/XSoundNotify/src
parent871410044ecbac0d2dd67a7c98f8bcd2df9410eb (diff)
- naming conflict;
- warning fixes; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@14988 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/XSoundNotify/src')
-rw-r--r--plugins/XSoundNotify/src/dialog.cpp202
1 files changed, 95 insertions, 107 deletions
diff --git a/plugins/XSoundNotify/src/dialog.cpp b/plugins/XSoundNotify/src/dialog.cpp
index 142e178c95..6de7c5a28e 100644
--- a/plugins/XSoundNotify/src/dialog.cpp
+++ b/plugins/XSoundNotify/src/dialog.cpp
@@ -11,74 +11,73 @@ There is no warranty.
static INT_PTR CALLBACK DlgProcContactsOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
+ MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ XSN_Data *p;
+
switch (msg) {
case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- MCONTACT hContact = lParam;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- WindowList_Add(hChangeSoundDlgList, hwndDlg, hContact);
- Utils_RestoreWindowPositionNoSize(hwndDlg, hContact, SETTINGSNAME, "ChangeSoundDlg");
- char* szProto = GetContactProto(hContact);
- PROTOACCOUNT *pa = Proto_GetAccount(szProto);
- char* szUniqueId = (char*)CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
- if ((INT_PTR)szUniqueId != CALLSERVICE_NOTFOUND && szUniqueId != NULL) {
- DBVARIANT dbvuid = { 0 };
- if (!db_get(hContact, pa->szModuleName, szUniqueId, &dbvuid)) {
- TCHAR uid[MAX_PATH];
- switch (dbvuid.type) {
- case DBVT_DWORD:
- _itot(dbvuid.dVal, uid, 10);
- break;
-
- case DBVT_ASCIIZ:
- mir_tstrcpy(uid, _A2T(dbvuid.pszVal));
- break;
-
- case DBVT_UTF8:
- mir_tstrcpy(uid, ptrT(mir_utf8decodeT(dbvuid.pszVal)));
- break;
+ {
+ TranslateDialogDefault(hwndDlg);
+ hContact = lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+ WindowList_Add(hChangeSoundDlgList, hwndDlg, hContact);
+ Utils_RestoreWindowPositionNoSize(hwndDlg, hContact, SETTINGSNAME, "ChangeSoundDlg");
+ char* szProto = GetContactProto(hContact);
+ PROTOACCOUNT *pa = Proto_GetAccount(szProto);
+ char* szUniqueId = (char*)CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
+ if ((INT_PTR)szUniqueId != CALLSERVICE_NOTFOUND && szUniqueId != NULL) {
+ DBVARIANT dbvuid = { 0 };
+ if (!db_get(hContact, pa->szModuleName, szUniqueId, &dbvuid)) {
+ TCHAR uid[MAX_PATH];
+ switch (dbvuid.type) {
+ case DBVT_DWORD:
+ _itot(dbvuid.dVal, uid, 10);
+ break;
+
+ case DBVT_ASCIIZ:
+ mir_tstrcpy(uid, _A2T(dbvuid.pszVal));
+ break;
+
+ case DBVT_UTF8:
+ mir_tstrcpy(uid, ptrT(mir_utf8decodeT(dbvuid.pszVal)));
+ break;
+ }
+
+ TCHAR *nick = (TCHAR *)pcli->pfnGetContactDisplayName(hContact, 0);
+ TCHAR value[100];
+ mir_sntprintf(value, _countof(value), TranslateT("Custom sound for %s (%s)"), nick, uid);
+ SetWindowText(hwndDlg, value);
+ db_free(&dbvuid);
}
-
- TCHAR *nick = (TCHAR *)pcli->pfnGetContactDisplayName(hContact, 0);
- TCHAR value[100];
- mir_sntprintf(value, _countof(value), TranslateT("Custom sound for %s (%s)"), nick, uid);
- SetWindowText(hwndDlg, value);
- db_free(&dbvuid);
}
- }
- EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_CHOOSE_SOUND), TRUE);
- DBVARIANT dbv = { 0 };
- if (!db_get_ts(hContact, SETTINGSNAME, SETTINGSKEY, &dbv)) {
- EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_TEST_PLAY), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_RESET_SOUND), TRUE);
- SetDlgItemText(hwndDlg, IDC_CONT_LABEL_SOUND, PathFindFileName(dbv.ptszVal));
- db_free(&dbv);
- }
- else {
- EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_TEST_PLAY), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_RESET_SOUND), FALSE);
- SetDlgItemText(hwndDlg, IDC_CONT_LABEL_SOUND, TranslateT("Not set"));
- }
- EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_IGNORE_SOUND), TRUE);
- CheckDlgButton(hwndDlg, IDC_CONT_IGNORE_SOUND, db_get_b(hContact, SETTINGSNAME, SETTINGSIGNOREKEY, 0) ? BST_CHECKED : BST_UNCHECKED);
- XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
- if (p == NULL) {
- DBVARIANT dbv;
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_CHOOSE_SOUND), TRUE);
+ DBVARIANT dbv = { 0 };
if (!db_get_ts(hContact, SETTINGSNAME, SETTINGSKEY, &dbv)) {
- XSN_Users.insert(new XSN_Data(hContact, dbv.ptszVal, IsDlgButtonChecked(hwndDlg, IDC_CONT_IGNORE_SOUND) ? 1 : 0));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_TEST_PLAY), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_RESET_SOUND), TRUE);
+ SetDlgItemText(hwndDlg, IDC_CONT_LABEL_SOUND, PathFindFileName(dbv.ptszVal));
db_free(&dbv);
}
+ else {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_TEST_PLAY), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_RESET_SOUND), FALSE);
+ SetDlgItemText(hwndDlg, IDC_CONT_LABEL_SOUND, TranslateT("Not set"));
+ }
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_IGNORE_SOUND), TRUE);
+ CheckDlgButton(hwndDlg, IDC_CONT_IGNORE_SOUND, db_get_b(hContact, SETTINGSNAME, SETTINGSIGNOREKEY, 0) ? BST_CHECKED : BST_UNCHECKED);
+ p = XSN_Users.find((XSN_Data *)&hContact);
+ if (p == NULL) {
+ ptrT name(db_get_tsa(hContact, SETTINGSNAME, SETTINGSKEY));
+ if (name != NULL)
+ XSN_Users.insert(new XSN_Data(hContact, name, IsDlgButtonChecked(hwndDlg, IDC_CONT_IGNORE_SOUND) ? 1 : 0));
+ }
}
- }
- return TRUE;
+ return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
- {
- MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
+ p = XSN_Users.find((XSN_Data *)&hContact);
if (p != NULL) {
if (mir_tstrcmpi(p->path, _T(""))) {
TCHAR shortpath[MAX_PATH];
@@ -87,55 +86,51 @@ static INT_PTR CALLBACK DlgProcContactsOptions(HWND hwndDlg, UINT msg, WPARAM wP
}
db_set_b(hContact, SETTINGSNAME, SETTINGSIGNOREKEY, p->ignore);
}
- }
case IDCANCEL:
DestroyWindow(hwndDlg);
break;
case IDC_CONT_BUTTON_CHOOSE_SOUND:
- {
- TCHAR FileName[MAX_PATH];
- TCHAR *tszMirDir = Utils_ReplaceVarsT(_T("%miranda_path%"));
-
- OPENFILENAME ofn = { 0 };
- ofn.lStructSize = sizeof(ofn);
- TCHAR tmp[MAX_PATH];
- if (GetModuleHandle(_T("bass_interface.dll")))
- mir_sntprintf(tmp, _countof(tmp), _T("%s (*.wav, *.mp3, *.ogg)%c*.wav;*.mp3;*.ogg%c%c"), TranslateT("Sound files"), 0, 0, 0);
- else
- mir_sntprintf(tmp, _countof(tmp), _T("%s (*.wav)%c*.wav%c%c"), TranslateT("WAV files"), 0, 0, 0);
- ofn.lpstrFilter = tmp;
- ofn.hwndOwner = 0;
- ofn.lpstrFile = FileName;
- ofn.nMaxFile = MAX_PATH;
- ofn.nMaxFileTitle = MAX_PATH;
- ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
- ofn.lpstrInitialDir = tszMirDir;
- *FileName = '\0';
- ofn.lpstrDefExt = _T("");
-
- if (GetOpenFileName(&ofn)) {
- MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- SetDlgItemText(hwndDlg, IDC_CONT_LABEL_SOUND, PathFindFileName(FileName));
- XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
- if (p == NULL)
- XSN_Users.insert(new XSN_Data(hContact, FileName, IsDlgButtonChecked(hwndDlg, IDC_CONT_IGNORE_SOUND) ? 1 : 0));
- else {
- _tcsncpy(p->path, FileName, _countof(p->path));
- p->ignore = IsDlgButtonChecked(hwndDlg, IDC_CONT_IGNORE_SOUND) ? 1 : 0;
+ {
+ TCHAR FileName[MAX_PATH];
+ TCHAR *tszMirDir = Utils_ReplaceVarsT(_T("%miranda_path%"));
+
+ OPENFILENAME ofn = { 0 };
+ ofn.lStructSize = sizeof(ofn);
+ TCHAR tmp[MAX_PATH];
+ if (GetModuleHandle(_T("bass_interface.dll")))
+ mir_sntprintf(tmp, _countof(tmp), _T("%s (*.wav, *.mp3, *.ogg)%c*.wav;*.mp3;*.ogg%c%c"), TranslateT("Sound files"), 0, 0, 0);
+ else
+ mir_sntprintf(tmp, _countof(tmp), _T("%s (*.wav)%c*.wav%c%c"), TranslateT("WAV files"), 0, 0, 0);
+ ofn.lpstrFilter = tmp;
+ ofn.hwndOwner = 0;
+ ofn.lpstrFile = FileName;
+ ofn.nMaxFile = MAX_PATH;
+ ofn.nMaxFileTitle = MAX_PATH;
+ ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
+ ofn.lpstrInitialDir = tszMirDir;
+ *FileName = '\0';
+ ofn.lpstrDefExt = _T("");
+
+ if (GetOpenFileName(&ofn)) {
+ SetDlgItemText(hwndDlg, IDC_CONT_LABEL_SOUND, PathFindFileName(FileName));
+ p = XSN_Users.find((XSN_Data *)&hContact);
+ if (p == NULL)
+ XSN_Users.insert(new XSN_Data(hContact, FileName, IsDlgButtonChecked(hwndDlg, IDC_CONT_IGNORE_SOUND) ? 1 : 0));
+ else {
+ _tcsncpy(p->path, FileName, _countof(p->path));
+ p->ignore = IsDlgButtonChecked(hwndDlg, IDC_CONT_IGNORE_SOUND) ? 1 : 0;
+ }
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_TEST_PLAY), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_RESET_SOUND), TRUE);
}
- EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_TEST_PLAY), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_RESET_SOUND), TRUE);
+ mir_free(tszMirDir);
}
- mir_free(tszMirDir);
- }
- break;
+ break;
case IDC_CONT_BUTTON_TEST_PLAY:
- {
- MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
+ p = XSN_Users.find((XSN_Data *)&hContact);
isIgnoreSound = 0;
if (p == NULL) {
DBVARIANT dbv;
@@ -151,30 +146,25 @@ static INT_PTR CALLBACK DlgProcContactsOptions(HWND hwndDlg, UINT msg, WPARAM wP
PathToAbsoluteT(p->path, longpath);
SkinPlaySoundFile(longpath);
}
- }
- break;
+ break;
case IDC_CONT_BUTTON_RESET_SOUND:
- {
- MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_TEST_PLAY), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_RESET_SOUND), FALSE);
CheckDlgButton(hwndDlg, IDC_CONT_IGNORE_SOUND, BST_UNCHECKED);
SetDlgItemText(hwndDlg, IDC_CONT_LABEL_SOUND, TranslateT("Not set"));
- XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
+
+ p = XSN_Users.find((XSN_Data *)&hContact);
if (p != NULL) {
XSN_Users.remove(p);
delete p;
}
db_unset(hContact, SETTINGSNAME, SETTINGSKEY);
db_unset(hContact, SETTINGSNAME, SETTINGSIGNOREKEY);
- }
- break;
+ break;
case IDC_CONT_IGNORE_SOUND:
- {
- MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
+ p = XSN_Users.find((XSN_Data *)&hContact);
if (p == NULL) {
DBVARIANT dbv;
if (!db_get_ts(hContact, SETTINGSNAME, SETTINGSKEY, &dbv)) {
@@ -187,7 +177,6 @@ static INT_PTR CALLBACK DlgProcContactsOptions(HWND hwndDlg, UINT msg, WPARAM wP
}
else p->ignore = IsDlgButtonChecked(hwndDlg, IDC_CONT_IGNORE_SOUND) ? 1 : 0;
}
- }
break;
case WM_CLOSE:
@@ -195,7 +184,6 @@ static INT_PTR CALLBACK DlgProcContactsOptions(HWND hwndDlg, UINT msg, WPARAM wP
break;
case WM_DESTROY:
- MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
Utils_SaveWindowPosition(hwndDlg, hContact, SETTINGSNAME, "ChangeSoundDlg");
WindowList_Remove(hChangeSoundDlgList, hwndDlg);
}