diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2014-12-11 21:45:07 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2014-12-11 21:45:07 +0000 |
commit | ee0f577f3169211400f03b6fe012686c416c34da (patch) | |
tree | c141fadf30f549d0cd4f481ce84bfe6622b6710a /plugins/XSoundNotify/src | |
parent | d74103c8def2fdf60ca5cf8981a3558bc9728b31 (diff) |
XSoundNotify: added chat rooms support
git-svn-id: http://svn.miranda-ng.org/main/trunk@11338 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/XSoundNotify/src')
-rw-r--r-- | plugins/XSoundNotify/src/Common.h | 1 | ||||
-rw-r--r-- | plugins/XSoundNotify/src/dialog.cpp | 286 | ||||
-rw-r--r-- | plugins/XSoundNotify/src/options.cpp | 197 | ||||
-rw-r--r-- | plugins/XSoundNotify/src/xsn_main.cpp | 94 |
4 files changed, 308 insertions, 270 deletions
diff --git a/plugins/XSoundNotify/src/Common.h b/plugins/XSoundNotify/src/Common.h index d635ed6079..4cbed8f0fb 100644 --- a/plugins/XSoundNotify/src/Common.h +++ b/plugins/XSoundNotify/src/Common.h @@ -13,6 +13,7 @@ #include <m_skin.h>
#include <win2k.h>
#include <m_options.h>
+#include <m_chat_int.h>
#include "resource.h"
#include "Version.h"
diff --git a/plugins/XSoundNotify/src/dialog.cpp b/plugins/XSoundNotify/src/dialog.cpp index 2da59d9130..9967551f53 100644 --- a/plugins/XSoundNotify/src/dialog.cpp +++ b/plugins/XSoundNotify/src/dialog.cpp @@ -13,180 +13,180 @@ static INT_PTR CALLBACK DlgProcContactsOptions(HWND hwndDlg, UINT msg, WPARAM wP {
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 = ProtoGetAccount(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:
- _tcscpy(uid, _A2T(dbvuid.pszVal));
- break;
-
- case DBVT_UTF8:
- _tcscpy(uid, ptrT( mir_utf8decodeT(dbvuid.pszVal)));
- break;
- }
-
- TCHAR *nick = (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR);
- TCHAR value[100];
- mir_sntprintf(value, SIZEOF(value), TranslateT("Custom sound for %s (%s)"), nick, uid);
- SetWindowText(hwndDlg, value);
- db_free(&dbvuid);
+ {
+ 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 = ProtoGetAccount(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:
+ _tcscpy(uid, _A2T(dbvuid.pszVal));
+ break;
+
+ case DBVT_UTF8:
+ _tcscpy(uid, ptrT(mir_utf8decodeT(dbvuid.pszVal)));
+ break;
}
+
+ TCHAR *nick = (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR);
+ TCHAR value[100];
+ mir_sntprintf(value, SIZEOF(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));
+ }
+ 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));
+ XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
+ if (p == NULL) {
+ DBVARIANT dbv;
+ 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));
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));
- XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
- if (p == NULL) {
- DBVARIANT dbv;
- 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));
- db_free(&dbv);
- }
- }
}
- 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);
- if (p != NULL) {
- if (mir_tstrcmpi(p->path, _T(""))) {
- TCHAR shortpath[MAX_PATH];
- PathToRelativeT(p->path, shortpath);
- db_set_ts(hContact, SETTINGSNAME, SETTINGSKEY, shortpath);
- }
- db_set_b(hContact, SETTINGSNAME, SETTINGSIGNOREKEY, p->ignore);
+ {
+ MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
+ if (p != NULL) {
+ if (mir_tstrcmpi(p->path, _T(""))) {
+ TCHAR shortpath[MAX_PATH];
+ PathToRelativeT(p->path, shortpath);
+ db_set_ts(hContact, SETTINGSNAME, SETTINGSKEY, shortpath);
}
+ 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, SIZEOF(tmp), _T("%s (*.wav, *.mp3, *.ogg)%c*.wav;*.mp3;*.ogg%c%c"), TranslateT("Sound files"), 0, 0, 0);
- else
- mir_sntprintf(tmp, SIZEOF(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, SIZEOF(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);
+ {
+ 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, SIZEOF(tmp), _T("%s (*.wav, *.mp3, *.ogg)%c*.wav;*.mp3;*.ogg%c%c"), TranslateT("Sound files"), 0, 0, 0);
+ else
+ mir_sntprintf(tmp, SIZEOF(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, SIZEOF(p->path));
+ p->ignore = IsDlgButtonChecked(hwndDlg, IDC_CONT_IGNORE_SOUND) ? 1 : 0;
}
- mir_free(tszMirDir);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_TEST_PLAY), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_RESET_SOUND), TRUE);
}
- break;
+ mir_free(tszMirDir);
+ }
+ break;
case IDC_CONT_BUTTON_TEST_PLAY:
- {
- MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
- isIgnoreSound = 0;
- if (p == NULL) {
- DBVARIANT dbv;
- if ( !db_get_ts(hContact, SETTINGSNAME, SETTINGSKEY, &dbv)) {
- TCHAR longpath[MAX_PATH] = {0};
- PathToAbsoluteT(dbv.ptszVal, longpath);
- SkinPlaySoundFile(longpath);
- db_free(&dbv);
- }
- }
- else {
- TCHAR longpath[MAX_PATH] = {0};
- PathToAbsoluteT(p->path, longpath);
+ {
+ MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
+ isIgnoreSound = 0;
+ if (p == NULL) {
+ DBVARIANT dbv;
+ if (!db_get_ts(hContact, SETTINGSNAME, SETTINGSKEY, &dbv)) {
+ TCHAR longpath[MAX_PATH] = { 0 };
+ PathToAbsoluteT(dbv.ptszVal, longpath);
SkinPlaySoundFile(longpath);
+ db_free(&dbv);
}
}
- break;
+ else {
+ TCHAR longpath[MAX_PATH] = { 0 };
+ PathToAbsoluteT(p->path, longpath);
+ SkinPlaySoundFile(longpath);
+ }
+ }
+ 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);
- if (p != NULL) {
- XSN_Users.remove(p);
- delete p;
- }
- db_unset(hContact, SETTINGSNAME, SETTINGSKEY);
- db_unset(hContact, SETTINGSNAME, SETTINGSIGNOREKEY);
+ {
+ 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);
+ if (p != NULL) {
+ XSN_Users.remove(p);
+ delete p;
}
- break;
+ db_unset(hContact, SETTINGSNAME, SETTINGSKEY);
+ db_unset(hContact, SETTINGSNAME, SETTINGSIGNOREKEY);
+ }
+ break;
case IDC_CONT_IGNORE_SOUND:
- {
- MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
- if (p == NULL) {
- DBVARIANT dbv;
- if ( !db_get_ts(hContact, SETTINGSNAME, SETTINGSKEY, &dbv)) {
- TCHAR longpath[MAX_PATH];
- PathToAbsoluteT(dbv.ptszVal, longpath);
- XSN_Users.insert( new XSN_Data(hContact, longpath, IsDlgButtonChecked(hwndDlg, IDC_CONT_IGNORE_SOUND) ? 1 : 0));
- db_free(&dbv);
- }
- else XSN_Users.insert( new XSN_Data(hContact, _T(""), IsDlgButtonChecked(hwndDlg, IDC_CONT_IGNORE_SOUND) ? 1 : 0));
+ {
+ MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
+ if (p == NULL) {
+ DBVARIANT dbv;
+ if (!db_get_ts(hContact, SETTINGSNAME, SETTINGSKEY, &dbv)) {
+ TCHAR longpath[MAX_PATH];
+ PathToAbsoluteT(dbv.ptszVal, longpath);
+ XSN_Users.insert(new XSN_Data(hContact, longpath, IsDlgButtonChecked(hwndDlg, IDC_CONT_IGNORE_SOUND) ? 1 : 0));
+ db_free(&dbv);
}
- else p->ignore = IsDlgButtonChecked(hwndDlg, IDC_CONT_IGNORE_SOUND) ? 1 : 0;
+ else XSN_Users.insert(new XSN_Data(hContact, _T(""), IsDlgButtonChecked(hwndDlg, IDC_CONT_IGNORE_SOUND) ? 1 : 0));
}
+ else p->ignore = IsDlgButtonChecked(hwndDlg, IDC_CONT_IGNORE_SOUND) ? 1 : 0;
+ }
}
break;
diff --git a/plugins/XSoundNotify/src/options.cpp b/plugins/XSoundNotify/src/options.cpp index 3b40596fac..8edc81db96 100644 --- a/plugins/XSoundNotify/src/options.cpp +++ b/plugins/XSoundNotify/src/options.cpp @@ -31,7 +31,7 @@ static INT_PTR CALLBACK OptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l int count;
PROTOACCOUNT **protos;
ProtoEnumAccounts(&count, &protos);
- for(int i = 0; i < count; i++)
+ for (int i = 0; i < count; i++)
if (IsSuitableProto(protos[i]))
SendMessage(GetDlgItem(hwndDlg, IDC_OPT_COMBO_PROTO), CB_SETITEMDATA, SendMessage(GetDlgItem(hwndDlg, IDC_OPT_COMBO_PROTO), CB_ADDSTRING, 0, (LPARAM)protos[i]->tszAccountName), (LPARAM)protos[i]);
return TRUE;
@@ -51,12 +51,16 @@ static INT_PTR CALLBACK OptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l PROTOACCOUNT *pa = (PROTOACCOUNT *)SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_PROTO, CB_GETITEMDATA, cursel, 0);
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- 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)) {
+ char *szUniqueId = NULL;
+ if (db_get_b(hContact, pa->szModuleName, "ChatRoom", 0))
+ szUniqueId = "ChatRoomID";
+ else
+ 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) {
+ switch (dbvuid.type) {
case DBVT_DWORD:
_itot(dbvuid.dVal, uid, 10);
break;
@@ -88,14 +92,15 @@ static INT_PTR CALLBACK OptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l int cursel = SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_USERS, CB_GETCURSEL, 0, 0);
MCONTACT hContact = (MCONTACT)SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_USERS, CB_GETITEMDATA, cursel, 0);
EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_BUTTON_CHOOSE_SOUND), TRUE);
- DBVARIANT dbv = {0};
- if ( !db_get_ts(hContact, SETTINGSNAME, SETTINGSKEY, &dbv))
+ DBVARIANT dbv = { 0 };
+ if (!db_get_ts(hContact, SETTINGSNAME, SETTINGSKEY, &dbv))
{
EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_BUTTON_TEST_PLAY), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_BUTTON_RESET_SOUND), TRUE);
SetDlgItemText(hwndDlg, IDC_OPT_LABEL_SOUND, PathFindFileName(dbv.ptszVal));
db_free(&dbv);
- } else {
+ }
+ else {
EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_BUTTON_TEST_PLAY), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_BUTTON_RESET_SOUND), FALSE);
SetDlgItemText(hwndDlg, IDC_OPT_LABEL_SOUND, TranslateT("Not set"));
@@ -106,108 +111,108 @@ static INT_PTR CALLBACK OptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l return 0;
case IDC_OPT_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, SIZEOF(tmp), _T("%s (*.wav, *.mp3, *.ogg)%c*.wav;*.mp3;*.ogg%c%c"), TranslateT("Sound files"), 0, 0, 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, SIZEOF(tmp), _T("%s (*.wav, *.mp3, *.ogg)%c*.wav;*.mp3;*.ogg%c%c"), TranslateT("Sound files"), 0, 0, 0);
+ else
+ mir_sntprintf(tmp, SIZEOF(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_OPT_LABEL_SOUND, PathFindFileName(FileName));
+ int cursel = SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_USERS, CB_GETCURSEL, 0, 0);
+ MCONTACT hContact = (MCONTACT)SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_USERS, CB_GETITEMDATA, cursel, 0);
+ XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
+ if (p == NULL)
+ XSN_Users.insert(new XSN_Data(hContact, FileName, IsDlgButtonChecked(hwndDlg, IDC_OPT_IGNORE_SOUND) ? 1 : 0));
else
- mir_sntprintf(tmp, SIZEOF(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_OPT_LABEL_SOUND, PathFindFileName(FileName));
- int cursel = SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_USERS, CB_GETCURSEL, 0, 0);
- MCONTACT hContact = (MCONTACT)SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_USERS, CB_GETITEMDATA, cursel, 0);
- XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
- if (p == NULL)
- XSN_Users.insert( new XSN_Data(hContact, FileName, IsDlgButtonChecked(hwndDlg, IDC_OPT_IGNORE_SOUND) ? 1 : 0));
- else
- {
- _tcsncpy(p->path, FileName, SIZEOF(p->path));
- p->ignore = IsDlgButtonChecked(hwndDlg, IDC_OPT_IGNORE_SOUND) ? 1 : 0;
- }
- EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_BUTTON_TEST_PLAY), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_BUTTON_RESET_SOUND), TRUE);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ {
+ _tcsncpy(p->path, FileName, SIZEOF(p->path));
+ p->ignore = IsDlgButtonChecked(hwndDlg, IDC_OPT_IGNORE_SOUND) ? 1 : 0;
}
- mir_free(tszMirDir);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_BUTTON_TEST_PLAY), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_BUTTON_RESET_SOUND), TRUE);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
- return 0;
+ mir_free(tszMirDir);
+ }
+ return 0;
case IDC_OPT_BUTTON_TEST_PLAY:
- {
- int cursel = SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_USERS, CB_GETCURSEL, 0, 0);
- MCONTACT hContact = (MCONTACT)SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_USERS, CB_GETITEMDATA, cursel, 0);
- XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
- isIgnoreSound = 0;
- if (p == NULL) {
- DBVARIANT dbv;
- if ( !db_get_ts(hContact, SETTINGSNAME, SETTINGSKEY, &dbv)) {
- TCHAR longpath[MAX_PATH];
- PathToAbsoluteT(dbv.ptszVal, longpath);
- SkinPlaySoundFile(longpath);
- db_free(&dbv);
- }
- }
- else {
- TCHAR longpath[MAX_PATH] = {0};
- PathToAbsoluteT(p->path, longpath);
+ {
+ int cursel = SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_USERS, CB_GETCURSEL, 0, 0);
+ MCONTACT hContact = (MCONTACT)SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_USERS, CB_GETITEMDATA, cursel, 0);
+ XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
+ isIgnoreSound = 0;
+ if (p == NULL) {
+ DBVARIANT dbv;
+ if (!db_get_ts(hContact, SETTINGSNAME, SETTINGSKEY, &dbv)) {
+ TCHAR longpath[MAX_PATH];
+ PathToAbsoluteT(dbv.ptszVal, longpath);
SkinPlaySoundFile(longpath);
+ db_free(&dbv);
}
}
- return 0;
+ else {
+ TCHAR longpath[MAX_PATH] = { 0 };
+ PathToAbsoluteT(p->path, longpath);
+ SkinPlaySoundFile(longpath);
+ }
+ }
+ return 0;
case IDC_OPT_BUTTON_RESET_SOUND:
- {
- EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_BUTTON_TEST_PLAY), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_BUTTON_RESET_SOUND), FALSE);
- CheckDlgButton(hwndDlg, IDC_OPT_IGNORE_SOUND, BST_UNCHECKED);
- SetDlgItemText(hwndDlg, IDC_OPT_LABEL_SOUND, TranslateT("Not set"));
- int cursel = SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_USERS, CB_GETCURSEL, 0, 0);
- MCONTACT hContact = (MCONTACT)SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_USERS, CB_GETITEMDATA, cursel, 0);
- XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
- if (p != NULL) {
- XSN_Users.remove(p);
- delete p;
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- db_unset(hContact, SETTINGSNAME, SETTINGSKEY);
- db_unset(hContact, SETTINGSNAME, SETTINGSIGNOREKEY);
+ {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_BUTTON_TEST_PLAY), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_BUTTON_RESET_SOUND), FALSE);
+ CheckDlgButton(hwndDlg, IDC_OPT_IGNORE_SOUND, BST_UNCHECKED);
+ SetDlgItemText(hwndDlg, IDC_OPT_LABEL_SOUND, TranslateT("Not set"));
+ int cursel = SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_USERS, CB_GETCURSEL, 0, 0);
+ MCONTACT hContact = (MCONTACT)SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_USERS, CB_GETITEMDATA, cursel, 0);
+ XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
+ if (p != NULL) {
+ XSN_Users.remove(p);
+ delete p;
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
- return 0;
+ db_unset(hContact, SETTINGSNAME, SETTINGSKEY);
+ db_unset(hContact, SETTINGSNAME, SETTINGSIGNOREKEY);
+ }
+ return 0;
case IDC_OPT_IGNORE_SOUND:
- {
- int cursel = SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_USERS, CB_GETCURSEL, 0, 0);
- MCONTACT hContact = (MCONTACT)SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_USERS, CB_GETITEMDATA, cursel, 0);
- XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
- if (p == NULL) {
- DBVARIANT dbv;
- if ( !db_get_ts(hContact, SETTINGSNAME, SETTINGSKEY, &dbv)) {
- TCHAR longpath[MAX_PATH];
- PathToAbsoluteT(dbv.ptszVal, longpath);
- XSN_Users.insert( new XSN_Data(hContact, longpath, IsDlgButtonChecked(hwndDlg, IDC_OPT_IGNORE_SOUND) ? 1 : 0));
- db_free(&dbv);
- }
- else XSN_Users.insert( new XSN_Data(hContact, _T(""), IsDlgButtonChecked(hwndDlg, IDC_OPT_IGNORE_SOUND) ? 1 : 0));
+ {
+ int cursel = SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_USERS, CB_GETCURSEL, 0, 0);
+ MCONTACT hContact = (MCONTACT)SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_USERS, CB_GETITEMDATA, cursel, 0);
+ XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
+ if (p == NULL) {
+ DBVARIANT dbv;
+ if (!db_get_ts(hContact, SETTINGSNAME, SETTINGSKEY, &dbv)) {
+ TCHAR longpath[MAX_PATH];
+ PathToAbsoluteT(dbv.ptszVal, longpath);
+ XSN_Users.insert(new XSN_Data(hContact, longpath, IsDlgButtonChecked(hwndDlg, IDC_OPT_IGNORE_SOUND) ? 1 : 0));
+ db_free(&dbv);
}
- else p->ignore = IsDlgButtonChecked(hwndDlg, IDC_OPT_IGNORE_SOUND) ? 1 : 0;
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ else XSN_Users.insert(new XSN_Data(hContact, _T(""), IsDlgButtonChecked(hwndDlg, IDC_OPT_IGNORE_SOUND) ? 1 : 0));
}
- return 0;
+ else p->ignore = IsDlgButtonChecked(hwndDlg, IDC_OPT_IGNORE_SOUND) ? 1 : 0;
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ return 0;
}
break;
diff --git a/plugins/XSoundNotify/src/xsn_main.cpp b/plugins/XSoundNotify/src/xsn_main.cpp index 2f83a7343d..35bdcec03d 100644 --- a/plugins/XSoundNotify/src/xsn_main.cpp +++ b/plugins/XSoundNotify/src/xsn_main.cpp @@ -16,6 +16,8 @@ HGENMENU hChangeSound = NULL; HANDLE hChangeSoundDlgList = NULL;
BYTE isIgnoreSound = 0, isOwnSound = 0;
+CHAT_MANAGER *pci;
+
PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
@@ -27,7 +29,7 @@ PLUGININFOEX pluginInfo = { __AUTHORWEB,
UNICODE_AWARE,
// {08B86253-EC6E-4D09-B7A9-64ACDF0627B8}
- {0x8b86253, 0xec6e, 0x4d09, {0xb7, 0xa9, 0x64, 0xac, 0xdf, 0x6, 0x27, 0xb8}}
+ { 0x8b86253, 0xec6e, 0x4d09, { 0xb7, 0xa9, 0x64, 0xac, 0xdf, 0x6, 0x27, 0xb8 } }
};
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
@@ -49,43 +51,43 @@ struct { }
static selfSounds[] =
{
- { ID_STATUS_OFFLINE, "SelfOffline"},
- { ID_STATUS_ONLINE, "SelfOnline"},
- { ID_STATUS_AWAY, "SelfAway"},
- { ID_STATUS_DND, "SelfDND"},
- { ID_STATUS_NA, "SelfNA"},
- { ID_STATUS_OCCUPIED, "SelfOccupied"},
- { ID_STATUS_FREECHAT, "SelfFreeForChat"},
- { ID_STATUS_INVISIBLE, "SelfInvisible"},
- { ID_STATUS_ONTHEPHONE, "SelfOnThePhone"},
- { ID_STATUS_OUTTOLUNCH, "SelfOutToLunch"}
+ { ID_STATUS_OFFLINE, "SelfOffline" },
+ { ID_STATUS_ONLINE, "SelfOnline" },
+ { ID_STATUS_AWAY, "SelfAway" },
+ { ID_STATUS_DND, "SelfDND" },
+ { ID_STATUS_NA, "SelfNA" },
+ { ID_STATUS_OCCUPIED, "SelfOccupied" },
+ { ID_STATUS_FREECHAT, "SelfFreeForChat" },
+ { ID_STATUS_INVISIBLE, "SelfInvisible" },
+ { ID_STATUS_ONTHEPHONE, "SelfOnThePhone" },
+ { ID_STATUS_OUTTOLUNCH, "SelfOutToLunch" }
};
void InitSelfSounds()
{
// initializing self sounds for protocols
- int protoCount=0;
+ int protoCount = 0;
PROTOACCOUNT** protos = 0;
- ProtoEnumAccounts(&protoCount,&protos);
+ ProtoEnumAccounts(&protoCount, &protos);
for (int i = 0; i < protoCount; i++) {
- for(int j = 0; j < SIZEOF(selfSounds); j++) {
+ for (int j = 0; j < SIZEOF(selfSounds); j++) {
char namebuf[128];
mir_snprintf(namebuf, SIZEOF(namebuf), "%s%s", protos[i]->szModuleName, selfSounds[j].szName);
-
+
TCHAR infobuf[256];
mir_sntprintf(infobuf, SIZEOF(infobuf), _T("%s [%s]"), TranslateT("Self status"), protos[i]->tszAccountName);
- SkinAddNewSoundExT(namebuf, infobuf, (TCHAR*) CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,selfSounds[j].iStatus,GSMDF_TCHAR));
+ SkinAddNewSoundExT(namebuf, infobuf, (TCHAR*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, selfSounds[j].iStatus, GSMDF_TCHAR));
}
}
}
static int ProtoAck(WPARAM wParam, LPARAM lParam)
{
- ACKDATA *ack = (ACKDATA*) lParam;
+ ACKDATA *ack = (ACKDATA*)lParam;
if (ack != 0 && ack->szModule && ack->type == ACKTYPE_STATUS && ack->result == ACKRESULT_SUCCESS) {
- for(int i = 0; i < SIZEOF(selfSounds); i++) {
- if(selfSounds[i].iStatus == ack->lParam) {
+ for (int i = 0; i < SIZEOF(selfSounds); i++) {
+ if (selfSounds[i].iStatus == ack->lParam) {
char buf[128];
mir_snprintf(buf, SIZEOF(buf), "%s%s", ack->szModule, selfSounds[i].szName);
SkinPlaySound(buf);
@@ -115,8 +117,9 @@ static int ProcessEvent(WPARAM hContact, LPARAM lParam) isIgnoreSound = db_get_b(hContact, SETTINGSNAME, SETTINGSIGNOREKEY, 0);
DBVARIANT dbv;
if (!isIgnoreSound && !db_get_ts(hContact, SETTINGSNAME, SETTINGSKEY, &dbv)) {
- TCHAR PlaySoundPath[MAX_PATH] = {0};
+ TCHAR PlaySoundPath[MAX_PATH] = { 0 };
PathToAbsoluteT(dbv.ptszVal, PlaySoundPath);
+ isOwnSound = 0;
SkinPlaySoundFile(PlaySoundPath);
db_free(&dbv);
isOwnSound = 1;
@@ -125,27 +128,55 @@ static int ProcessEvent(WPARAM hContact, LPARAM lParam) return 0;
}
+static int ProcessChatEvent(WPARAM, LPARAM lParam)
+{
+ GCEVENT *gce = (GCEVENT*)lParam;
+ if (gce == NULL || gce->pDest == NULL)
+ return 0;
+
+ GCDEST *gcd = (GCDEST*)gce->pDest;
+ if (gcd->iType != GC_EVENT_MESSAGE)
+ return 0;
+
+ MCONTACT hContact = pci->FindRoom(gcd->pszModule, gcd->ptszID);
+ if (hContact != 0) {
+ ptrT nick(db_get_tsa(hContact, gcd->pszModule, "MyNick"));
+ if (_tcsstr(gce->ptszText, nick)) {
+ isIgnoreSound = db_get_b(hContact, SETTINGSNAME, SETTINGSIGNOREKEY, 0);
+ DBVARIANT dbv;
+ if (!isIgnoreSound && !db_get_ts(hContact, SETTINGSNAME, SETTINGSKEY, &dbv)) {
+ TCHAR PlaySoundPath[MAX_PATH] = { 0 };
+ PathToAbsoluteT(dbv.ptszVal, PlaySoundPath);
+ isOwnSound = 0;
+ SkinPlaySoundFile(PlaySoundPath);
+ db_free(&dbv);
+ isOwnSound = 1;
+ }
+ }
+ }
+
+ return 0;
+}
+
static int OnPlaySound(WPARAM, LPARAM)
{
- if (isIgnoreSound)
+ if (isIgnoreSound || isOwnSound)
return 1;
- if (isOwnSound) {
- isOwnSound = 0;
- return 1;
- }
return 0;
}
static int OnLoadInit(WPARAM wParam, LPARAM lParam)
{
+ mir_getCI(NULL);
+
CLISTMENUITEM mi = { sizeof(mi) };
- mi.position = -0x7FFFFFFF;
- mi.flags = CMIF_TCHAR;
- mi.hIcon = LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
- mi.ptszName = LPGENT("Custom contact sound");
- mi.pszService = "XSoundNotify/ContactMenuCommand";
- hChangeSound = Menu_AddContactMenuItem(&mi);
+ mi.position = -0x7FFFFFFF;
+ mi.flags = CMIF_TCHAR;
+ mi.hIcon = LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
+ mi.ptszName = LPGENT("Custom contact sound");
+ mi.pszService = "XSoundNotify/ContactMenuCommand";
+ hChangeSound = Menu_AddContactMenuItem(&mi);
InitSelfSounds();
return 0;
@@ -179,6 +210,7 @@ extern "C" int __declspec(dllexport) Load() HookEvent(ME_PROTO_ACK, ProtoAck);
HookEvent(ME_OPT_INITIALISE, OptInit);
HookEvent(ME_DB_EVENT_ADDED, ProcessEvent);
+ HookEvent(ME_GC_HOOK_EVENT, ProcessChatEvent);
HookEvent(ME_SYSTEM_MODULESLOADED, OnLoadInit);
HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PrebuildContactMenu);
HookEvent(ME_SYSTEM_PRESHUTDOWN, OnPreShutdown);
|