summaryrefslogtreecommitdiff
path: root/plugins/XSoundNotify/src/xsn_main.cpp
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2014-12-11 21:45:07 +0000
committerKirill Volinsky <mataes2007@gmail.com>2014-12-11 21:45:07 +0000
commitee0f577f3169211400f03b6fe012686c416c34da (patch)
treec141fadf30f549d0cd4f481ce84bfe6622b6710a /plugins/XSoundNotify/src/xsn_main.cpp
parentd74103c8def2fdf60ca5cf8981a3558bc9728b31 (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/xsn_main.cpp')
-rw-r--r--plugins/XSoundNotify/src/xsn_main.cpp94
1 files changed, 63 insertions, 31 deletions
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);