1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
#include <windows.h>
#include "irctell.h"
#include <api/syscb/api_syscb.h>
#include <api/core/api_core.h>
#include "api__irctell.h"
#include <api/service/waservicefactory.h>
#include "dde.h"
#include <strsafe.h>
static WACIrctell Irctell;
extern "C" __declspec(dllexport) ifc_wa5component *GetWinamp5SystemComponent()
{
return &Irctell;
}
bool dotell=true;
api_syscb *sysCallbackApi=0;
api_core *core=0;
api_service *WASABI_API_SVC = 0;
void WACIrctell::RegisterServices(api_service *service)
{
WASABI_API_SVC = service;
waServiceFactory *sf = WASABI_API_SVC->service_getServiceByGuid(syscbApiServiceGuid);
if (sf) sysCallbackApi = reinterpret_cast<api_syscb *>(sf->getInterface());
sysCallbackApi->syscb_registerCallback(static_cast<SysCallback *>(this));
sf = WASABI_API_SVC->service_getServiceByGuid(coreApiServiceGuid);
if (sf) core = reinterpret_cast<api_core *>(sf->getInterface());
if (core)
core->core_addCallback(0, this);
}
void WACIrctell::DeregisterServices(api_service *service)
{
// be sure to delete all your windows etc HERE, not in the destructor
// because the API pointer might be invalid in the destructor
// if (core)
// core->core_delCallback(0, this);
}
/*
void WACIrctell::onRegisterServices() {
dotell.setName("Enabled");
dotell=0;
registerAttribute(&dotell);
appstr.setName("DDE Target");
appstr="mIRC";
registerAttribute(&appstr);
cmdstr.setName("DDE Command");
cmdstr="/me is listening to %s";
registerAttribute(&cmdstr);
}
*/
int WACIrctell::ccb_notify(int msg, int param1, int param2)
{
if (msg==TITLECHANGE && dotell)
{
const wchar_t *title = (const wchar_t *)param1;
const wchar_t *cur=core->core_getCurrent(0);
wchar_t msg[256];
StringCchPrintfW(msg, 256, L"/describe #winamp is now listening to \"%s\"", title);
DdeCom::sendCommand(L"mIRC", msg, 1000);
}
return 0;
}
FOURCC WACIrctell::getEventType()
{
return SysCallback::SERVICE;
}
int WACIrctell::notify(int msg, int param1, int param2)
{
switch(msg)
{
case SvcCallback::ONREGISTER:
{
waServiceFactory *sf = (waServiceFactory *)param2;
if (sf->getGuid() == coreApiServiceGuid)
{
core = reinterpret_cast<api_core *>(sf->getInterface());
core->core_addCallback(0, this);
}
}
break;
case SvcNotify::ONDEREGISTERED:
{
waServiceFactory *sf = (waServiceFactory *)param2;
if (sf->getGuid() == coreApiServiceGuid)
{
if (core)
core->core_delCallback(0, this);
core = 0;
}
}
break;
}
return 0;
}
#define CBCLASS WACIrctell
START_MULTIPATCH;
START_PATCH(patch_wa5)
M_VCB(patch_wa5, ifc_wa5component, API_WA5COMPONENT_REGISTERSERVICES, RegisterServices);
M_VCB(patch_wa5, ifc_wa5component, API_WA5COMPONENT_DEREEGISTERSERVICES, DeregisterServices);
NEXT_PATCH(patch_core)
M_CB(patch_core, CoreCallback, CCB_NOTIFY, ccb_notify);
NEXT_PATCH(patch_svc)
M_CB(patch_svc, SysCallback, SYSCALLBACK_GETEVENTTYPE, getEventType);
M_CB(patch_svc, SysCallback, SYSCALLBACK_NOTIFY, notify);
END_PATCH
END_MULTIPATCH;
#undef CBCLASS
|