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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
{.$DEFINE CHANGE_NAME_BUFFERED}
{$include compilers.inc}
{$IFDEF COMPILER_16_UP}
{$WEAKLINKRTTI ON}
{.$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}
{$ENDIF}
{$IMAGEBASE $13300000}
library mradio;
uses
// FastMM4,
Windows,messages,commctrl
,common,io,wrapper,wrapdlgs,syswin
,Dynamic_Bass
,m_api,dbsettings,mirutils,mircontacts,memini,
rbass,rglobal,rccenter,rframeapi,roptions;
{$include mr_rc.inc}
{$r mradio.res}
{$r version.res}
{$include i_search.inc}
{$include i_variables.inc}
{$include i_service.inc}
{$include i_myservice.inc}
{$include i_hotkey.inc}
{$include i_tray.inc}
{$include i_visual.inc}
{$include i_optdlg.inc}
function OnModulesLoaded(wParam:WPARAM;lParam:LPARAM):int;cdecl;
var
nlu:TNETLIBUSER;
buf:array [0..MAX_PATH-1] of WideChar;
szTemp:array [0..255] of AnsiChar absolute buf;
pc:pWideChar;
begin
// buf = miranda directory
// must be same as %miranda_path% of MS_UTILS_REPLACEVARS
GetModuleFileNameW(0,buf,MAX_PATH-1);
pc:=StrEndW(buf);
repeat
dec(pc);
until pc^='\';
inc(pc);
pc^:=#0;
// INI file path
StrCopyW(pc,'plugins\mradio.ini');
FastWideToAnsi(buf,storage);
mGetMem(storagep,MAX_PATH+32);
Profile_GetPathA(MAX_PATH,storagep);
StrCat(storagep,'\mradio.ini');
DBWriteDWord(0,PluginName,optVersion,PluginInfo.version); //??
RegisterIcons;
CreateMenu;
CreateMIMTrayMenu;
//-- network (for proxy)
FillChar(nlu,SizeOf(nlu),0);
StrCopy(szTemp,Translate('%s server connection'));
StrReplace(szTemp,'%s',PluginName);
nlu.szDescriptiveName.a:=szTemp;
nlu.flags :=NUF_HTTPCONNS or NUF_NOHTTPSOPTION or NUF_OUTGOING;
nlu.szSettingsModule :=PluginName;
hNetLib:=Netlib_RegisterUser(@nlu);
// CallService(MS_RADIO_COMMAND,MRC_RECORD,2); record off - not so necessary
LoadPresets;
LoadSettings;
SetStatus(0,ID_STATUS_OFFLINE);
CallService(MS_RADIO_COMMAND,MRC_STATUS,RD_STATUS_NOSTATION);
IsMultiThread:=true;
RegisterVariables;
HookEvent(ME_DB_CONTACT_SETTINGCHANGED,@OnSettingsChanged);
HookEvent(ME_DB_CONTACT_DELETED ,@OnContactDeleted);
randomize;
CreateFrame(0);
RegisterHotKey;
result:=0;
end;
function PreShutdown(wParam:WPARAM;lParam:LPARAM):int;cdecl;
{
var
buf:array [0..MAX_PATH-1] of AnsiChar;
fdata:WIN32_FIND_DATAA;
p:pAnsiChar;
fi:THANDLE;
}
begin
RemoveTrayItems;
CallService(MS_RADIO_COMMAND,MRC_STOP,1);
UnregisterHotKey;
DestroyProtoServices;
DestroyFrame();
MyUnloadBass;
DBWriteByte(0,PluginName,optVolume,gVolume);
DestroyHookableEvent(hhRadioStatus);
Netlib_CloseHandle(hNetLib);
mFreeMem(storage);
mFreeMem(storagep);
FreePresets;
FreeSettings;
{
//delete cover files
buf[0]:=#0;
GetTempPathA(MAX_PATH,buf);
p:=StrEnd(buf);
StrCopy(p,'mrAvt*.*');
fi:=FindFirstFileA(buf,fdata);
if fi<>THANDLE(INVALID_HANDLE_VALUE) then
begin
repeat
StrCopy(p,fdata.cFileName);
DeleteFileA(buf);
until not FindNextFileA(fi,fdata);
FindClose(fi);
end;
}
result:=0;
end;
function Load: int; cdecl;
begin
Langpack_register;
// hooks and services
hhRadioStatus:=CreateHookableEvent(ME_RADIO_STATUS);
CreateServiceFunction(MS_RADIO_PLAYSTOP ,@Service_RadioPlayStop);
CreateServiceFunction(MS_RADIO_RECORD ,@Service_RadioRecord);
CreateServiceFunction(MS_RADIO_SETTINGS ,@Service_RadioSettings);
CreateServiceFunction(MS_RADIO_SETVOL ,@Service_RadioSetVolume);
CreateServiceFunction(MS_RADIO_GETVOL ,@Service_RadioGetVolume);
CreateServiceFunction(MS_RADIO_MUTE ,@Service_RadioMute);
CreateServiceFunction(MS_RADIO_COMMAND ,@ControlCenter);
CreateServiceFunction(MS_RADIO_EQONOFF ,@Service_EqOnOff);
CreateServiceFunction(MS_RADIO_TRAYMENU ,@CreateTrayMenu);
CreateServiceFunction(MS_RADIO_QUICKOPEN,@QuickOpen);
CreateServiceFunction(MS_RADIO_EXPORT ,@ExportAll);
CreateServiceFunction(MS_RADIO_IMPORT ,@ImportAll);
CreateProtoServices;
HookEvent(ME_SYSTEM_MODULESLOADED ,@OnModulesLoaded);
HookEvent(ME_SYSTEM_OKTOEXIT ,@PreShutdown);
HookEvent(ME_CLIST_DOUBLECLICKED ,@Service_RadioPlayStop{@DblClickProc});
HookEvent(ME_OPT_INITIALISE ,@OnOptInitialise);
HookEvent(ME_CLIST_PREBUILDCONTACTMENU,@OnContactMenu);
PluginStatus:=ID_STATUS_OFFLINE;
Result:=0;
end;
function Unload: int; cdecl;
begin
Result:=0;
end;
exports
Load, Unload;
begin
// register protocol
Proto_RegisterModule(PROTOTYPE_VIRTUAL,PluginName);
Proto_SetUniqueId(PluginName,optStationURL);
DisableThreadLibraryCalls(hInstance);
PluginInfo.cbSize :=SizeOf(TPLUGININFOEX);
PluginInfo.shortName :='mRadio Mod';
PluginInfo.version :=$00000204;
PluginInfo.description:='This plugin plays and records Internet radio streams.'+
' Also local media files can be played.';
PluginInfo.author :='Awkward';
PluginInfo.copyright :='(c) 2007-14 Awkward';
PluginInfo.homepage :='https://miranda-ng.org/p/MRadio/';
PluginInfo.flags :=UNICODE_AWARE;
PluginInfo.uuid :=MIID_MRADIO;
end.
|