summaryrefslogtreecommitdiff
path: root/plugins/mRadio/rglobal.pas
blob: d914d4dc21800b5d28f3eb1644fbecd6a84c7bdf (plain)
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
{used variables}
unit rglobal;

interface

uses
  windows,
  Dynamic_Bass,
  m_api,
  playlist;

{$include m_radio.inc}

const
  cPluginName = 'mRadio';
const
  PluginName:PAnsiChar = cPluginName;

const
  BassStatus:(rbs_null,rbs_load,rbs_init) = rbs_null;

const
  chan         :HSTREAM = 0;
  ActiveContact:HCONTACT = 0;
  ActiveURL    :PWideChar = nil;

const
  optVolume     :PAnsiChar = 'Volume';

  optVersion    :PAnsiChar = 'version'; //??

  // mRadio compatibility
//optStationurl <<
  optMyHandle   :PAnsiChar = 'MyHandle';
  optGenre      :PAnsiChar = 'Genre';
  optBitrate    :PAnsiChar = 'Bitrate';
  // UserInfo compatibility
  optFirstName  :PAnsiChar = 'FirstName';
  optNick       :PAnsiChar = 'Nick';
  optLastName   :PAnsiChar = 'LastName';
  optAge        :PAnsiChar = 'Age';

  optGroup      :PAnsiChar = 'Group';

const
  optEAXType    :PAnsiChar = 'EAXtype';
  optStatusMsg  :PAnsiChar = 'StatusMsg';
  optBASSPath   :PAnsiChar = 'BASSpath';

  optLastStn    :PAnsiChar = 'LastStation';
  optActiveCodec:PAnsiChar = 'ActiveCodec';
  optStationURL :PAnsiChar = 'StationURL'; // mRadio compatibility
const
  optTitle      :PAnsiChar = 'Title';
  optArtist     :PAnsiChar = 'Artist';
  optStatus     :PAnsiChar = 'Status';

var
  hhRadioStatus,
  hNetLib:THANDLE;
var
  plist:tPlaylist;
//  plFile:pWideChar; // playlist file name (for delete after using?)
//  plLocal:boolean;  // true - no need to delete playlist
var
  RemoteSong:bool;
  gVolume:integer;
  NumTries:cardinal;
  doLoop:cardinal;
  PlayFirst:cardinal;
  doShuffle:cardinal;
  ForcedMono:cardinal;
  doContRec:cardinal;
  AuConnect:cardinal;
  AuMute:cardinal;
  AsOffline:cardinal;
  isEQ_OFF:cardinal;
  PluginStatus:integer;
  storagep,storage:PAnsiChar;
  recpath:pWideChar;
  StatusTmpl:pWideChar;
  sBuffer,
  sTimeout,
  sPreBuf:cardinal;
  usedevice:PAnsiChar;

const // inside INC files only
  hVolCtrl:HWND=0;

//----- Equalizer -----

type
  tEQRec = record
    fx    :HFX;
    wnd   :HWND;
    param :BASS_DX8_PARAMEQ;
    text  :PAnsiChar;
  end;
var
  eq:array [0..9] of tEQRec = (
    (fx:0;wnd:0;param:(fCenter:80   ;fBandwidth:18;fGain:0);text:'80'),
    (fx:0;wnd:0;param:(fCenter:170  ;fBandwidth:18;fGain:0);text:'170'),
    (fx:0;wnd:0;param:(fCenter:310  ;fBandwidth:18;fGain:0);text:'310'),
    (fx:0;wnd:0;param:(fCenter:600  ;fBandwidth:18;fGain:0);text:'600'),
    (fx:0;wnd:0;param:(fCenter:1000 ;fBandwidth:18;fGain:0);text:'1k'),
    (fx:0;wnd:0;param:(fCenter:3000 ;fBandwidth:18;fGain:0);text:'3k'),
    (fx:0;wnd:0;param:(fCenter:6000 ;fBandwidth:18;fGain:0);text:'6k'),
    (fx:0;wnd:0;param:(fCenter:12000;fBandwidth:18;fGain:0);text:'12k'),
    (fx:0;wnd:0;param:(fCenter:14000;fBandwidth:18;fGain:0);text:'14k'),
    (fx:0;wnd:0;param:(fCenter:16000;fBandwidth:18;fGain:0);text:'16k'));

//----- Button icons -----

const
  IcoBtnSettings:PAnsiChar = 'Radio_Setting';
  IcoBtnOn      :PAnsiChar = 'Radio_On';
  IcoBtnOff     :PAnsiChar = 'Radio_Off';
  IcoBtnRecUp   :PAnsiChar = 'Radio_RecUp';
  IcoBtnRecDn   :PAnsiChar = 'Radio_RecDn';
  IcoBtnAdd     :PAnsiChar = 'Radio_Add';
  IcoBtnDel     :PAnsiChar = 'Radio_Del';

//----- EAX -----

type
  TEAXItem = record
    name:PWideChar;
    code:dword;
  end;
const
  EAXItems:array [0..EAX_ENVIRONMENT_COUNT] of TEAXItem=(
    (name:'Off'             ; code:0),
    (name:'Generic'         ; code:EAX_ENVIRONMENT_GENERIC),
    (name:'Padded Cell'     ; code:EAX_ENVIRONMENT_PADDEDCELL),
    (name:'Room'            ; code:EAX_ENVIRONMENT_ROOM),
    (name:'Bathroom'        ; code:EAX_ENVIRONMENT_BATHROOM),
    (name:'Living Room'     ; code:EAX_ENVIRONMENT_LIVINGROOM),
    (name:'Stone Room'      ; code:EAX_ENVIRONMENT_STONEROOM),
    (name:'Auditorium'      ; code:EAX_ENVIRONMENT_AUDITORIUM),
    (name:'Concert Hall'    ; code:EAX_ENVIRONMENT_CONCERTHALL),
    (name:'Cave'            ; code:EAX_ENVIRONMENT_CAVE),
    (name:'Arena'           ; code:EAX_ENVIRONMENT_ARENA),
    (name:'Hangar'          ; code:EAX_ENVIRONMENT_HANGAR),
    (name:'Carpeted Hallway'; code:EAX_ENVIRONMENT_CARPETEDHALLWAY),
    (name:'Hallway'         ; code:EAX_ENVIRONMENT_HALLWAY),
    (name:'Stone Corridor'  ; code:EAX_ENVIRONMENT_STONECORRIDOR),
    (name:'Alley'           ; code:EAX_ENVIRONMENT_ALLEY),
    (name:'Forrest'         ; code:EAX_ENVIRONMENT_FOREST),
    (name:'City'            ; code:EAX_ENVIRONMENT_CITY),
    (name:'Mountains'       ; code:EAX_ENVIRONMENT_MOUNTAINS),
    (name:'Quarry'          ; code:EAX_ENVIRONMENT_QUARRY),
    (name:'Plain'           ; code:EAX_ENVIRONMENT_PLAIN),
    (name:'Parking Lot'     ; code:EAX_ENVIRONMENT_PARKINGLOT),
    (name:'Sewer Pipe'      ; code:EAX_ENVIRONMENT_SEWERPIPE),
    (name:'Under Water'     ; code:EAX_ENVIRONMENT_UNDERWATER),
    (name:'Drugged'         ; code:EAX_ENVIRONMENT_DRUGGED),
    (name:'Dizzy'           ; code:EAX_ENVIRONMENT_DIZZY),
    (name:'Psychotic'       ; code:EAX_ENVIRONMENT_PSYCHOTIC));


function MakeMessage:pWideChar;
procedure SetStatus(hContact:HCONTACT;status:integer);
function GetDefaultRecPath:pWideChar;
function GetStatusText(status:integer;toCList:boolean=false):PWideChar;


implementation

uses
  common, dbsettings;

procedure SetStatus(hContact:HCONTACT;status:integer);
begin
//  if Status=ID_STATUS_OFFLINE then
//    MyStopBass;

  if status=ID_STATUS_OFFLINE then
  begin
    if (AsOffline=BST_UNCHECKED) or (PluginStatus<>ID_STATUS_OFFLINE) then
      status:=ID_STATUS_INVISIBLE;
  end;

  if hContact=0 then
  begin
    hContact:=db_find_first(PluginName);
    while hContact<>0 do
    begin
      DBWriteWord(hContact,PluginName,optStatus,status);
      hContact:=db_find_next(hContact,PluginName);
    end;
  end
  else
    DBWriteWord(hContact,PluginName,optStatus,status);
end;

function MakeMessage:pWideChar;
var
  p,artist,title:pWideChar;
  len:cardinal;
begin
  artist:=DBReadUnicode(0,PluginName,optArtist);
  title :=DBReadUnicode(0,PluginName,optTitle);
  len:=StrLenW(artist);
  if (artist<>nil) and (title<>nil) then
    inc(len,3);
  inc(len,StrLenW(title));

  if len>0 then
  begin
    mGetMem(result,(len+1)*SizeOf(WideChar));
    p:=result;
    if artist<>nil then
    begin
      p:=StrCopyEW(p,artist);
      if title<>nil then
        p:=StrCopyEW(p,' - ');
      mFreeMem(artist);
    end;
    if title<>nil then
    begin
      StrCopyW(p,title);
      mFreeMem(title);
    end;
  end
  else
    result:=nil;
end;

function GetDefaultRecPath:pWideChar;
var
  dat:TREPLACEVARSDATA;
  mstr,szData:pWideChar;
  buf:array [0..MAX_PATH-1] of WideChar;
begin
  FillChar(dat,SizeOf(dat),0);
  dat.cbSize :=SizeOf(TREPLACEVARSDATA);
  dat.dwFlags:=RVF_UNICODE;
  szData:='%miranda_userdata%'+'\'+cPluginName;
  mstr:=pWideChar(CallService(MS_UTILS_REPLACEVARS, WPARAM(szData), LPARAM(@dat)));
  PathToRelativeW(mstr,buf);
  StrDupW(result,buf);
  mir_free(mstr);
end;

function GetStatusText(status:integer;toCList:boolean=false):PWideChar;
begin
  case status of
    RD_STATUS_PAUSED : result:='paused';
    RD_STATUS_STOPPED: if toCList then result:=nil else result:='stopped';
    RD_STATUS_CONNECT: result:='connecting';
    RD_STATUS_ABORT  : result:='aborting';
    RD_STATUS_PLAYING: if toCList then result:=nil else result:='playing';
  else
    result:=nil;
  end;
end;

end.