This repository has been archived by the owner on Feb 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fQIPPlugin.pas
2715 lines (2049 loc) · 83.9 KB
/
fQIPPlugin.pas
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit fQIPPlugin;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IniFiles, StdCtrls,
u_plugin_info, u_plugin_msg, u_common, ExtCtrls, Menus, ImgList;
type
{ TSpecCntUniq }
TSpecCntUniq = record
UniqID : DWord;
ItemType : DWord;
Index : DWord;
end;
pSpecCntUniq = ^TSpecCntUniq;
{ FadeMsg }
TFadeMsg = class
public
FadeType : Byte; //0 - message style, 1 - information style, 2 - warning style
FadeIcon : HICON; //icon in the top left corner of the window
FadeTitle : WideString;
FadeText : WideString;
TextCentered : Boolean; //if true then text will be centered inside window
NoAutoClose : Boolean; //if NoAutoClose is True then wnd will be always shown until user close it. Not recommended to set this param to True.
CloseTime : Integer;
pData : Integer;
end;
{ FadeMsgClosing }
TFadeMsgClosing = class
public
FadeID : DWord; //0 - message style, 1 - information style, 2 - warning style
Time : Integer; // 1 jednotka 500 ms.
end;
TfrmQIPPlugin = class(TForm)
tmrStep: TTimer;
tmrStart: TTimer;
pmContactMenu: TPopupMenu;
miContactMenu_OnOff: TMenuItem;
miContactMenu_Stations: TMenuItem;
miContactMenu_Formats: TMenuItem;
N1: TMenuItem;
miContactMenu_Informations: TMenuItem;
miContactMenu_Equalizer: TMenuItem;
miContactMenu_Recording: TMenuItem;
miContactMenu_EditStations: TMenuItem;
miContactMenu_Options: TMenuItem;
miContactMenu_Volume: TMenuItem;
ImageList1: TImageList;
miContactMenu_FastAddStation: TMenuItem;
tmrDraw: TTimer;
miContactMenu_CopySongName: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure tmrStepTimer(Sender: TObject);
procedure tmrStartTimer(Sender: TObject);
procedure miContactMenu_StationsClick(Sender: TObject);
procedure miContactMenu_FormatsClick(Sender: TObject);
procedure miContactMenu_InformationsClick(Sender: TObject);
procedure miContactMenu_EqualizerClick(Sender: TObject);
procedure miContactMenu_RecordingClick(Sender: TObject);
procedure miContactMenu_VolumeClick(Sender: TObject);
procedure miContactMenu_EditStationsClick(Sender: TObject);
procedure miContactMenu_OptionsClick(Sender: TObject);
procedure miContactMenu_OnOffClick(Sender: TObject);
procedure CMAdvDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
State: TOwnerDrawState);
procedure ddrrr(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Selected: Boolean);
procedure DrawMenu(Sender: TObject; ACanvas: TCanvas;
ARect: TRect; Selected: Boolean);
procedure MeasureMenu(Sender: TObject; ACanvas: TCanvas;
var Width, Height: Integer);
procedure miContactMenu_FastAddStationClick(Sender: TObject);
procedure tmrDrawTimer(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure miContactMenu_CopySongNameClick(Sender: TObject);
procedure pmContactMenuChange(Sender: TObject; Source: TMenuItem;
Rebuild: Boolean);
private
FPluginSvc : pIQIPPluginService;
FDllHandle : Cardinal;
FDllPath : WideString;
procedure WMHotKey(var msg:TWMHotKey);message WM_HOTKEY;
public
property PluginSvc : pIQIPPluginService read FPluginSvc write FPluginSvc;
property DllHandle : Cardinal read FDllHandle write FDllHandle;
property DllPath : WideString read FDllPath write FDllPath;
procedure CreateControls;
procedure FreeControls;
procedure LoadPluginOptions;
procedure SavePluginOptions;
procedure ShowPluginOptions;
// procedure SpellCheck(var PlugMsg: TPluginMessage);
// procedure SpellPopup(var PlugMsg: TPluginMessage);
procedure QipSoundChanged(PlugMsg: TPluginMessage);
procedure AntiBoss(HideForms: Boolean);
procedure CurrentLanguage(LangName: WideString);
procedure DrawSpecContact(PlugMsg: TPluginMessage);
procedure SpecContactDblClick(PlugMsg: TPluginMessage);
procedure SpecContactRightClick(PlugMsg: TPluginMessage);
procedure LeftClickOnFadeMsg(PlugMsg: TPluginMessage);
procedure GetSpecContactHintSize(var PlugMsg: TPluginMessage);
procedure DrawSpecContactHint(PlugMsg: TPluginMessage);
procedure XstatusChangedByUser(PlugMsg: TPluginMessage);
procedure InstantMsgRcvd(var PlugMsg: TPluginMessage);
procedure InstantMsgSend(var PlugMsg: TPluginMessage);
procedure NewMessageFlashing(PlugMsg: TPluginMessage);
procedure NewMessageStopFlashing(PlugMsg: TPluginMessage);
procedure AddNeededBtns(PlugMsg: TPluginMessage);
procedure MsgBtnClicked(PlugMsg: TPluginMessage);
procedure SpecMsgRcvd(PlugMsg: TPluginMessage);
procedure StatusChanged(PlugMsg: TPluginMessage);
procedure ImRcvdSuccess(PlugMsg: TPluginMessage);
procedure ContactStatusRcvd(PlugMsg: TPluginMessage);
procedure ChatTabAction(PlugMsg: TPluginMessage);
procedure AddNeededChatBtns(PlugMsg: TPluginMessage);
procedure ChatBtnClicked(PlugMsg: TPluginMessage);
procedure ChatMsgRcvd(PlugMsg: TPluginMessage);
procedure ChatMsgSending(var PlugMsg: TPluginMessage);
procedure EnumInfo(PlugMsg: TPluginMessage);
procedure DrawHint(Cnv: TCanvas; R : TRect; CalcRect: Boolean; var Width: Integer; var Height: Integer);
function FadeMsg(FType: Byte; FIcon: HICON; FTitle: WideString; FText: WideString; FTextCenter: Boolean; FNoAutoClose: Boolean; pData: Integer) : DWORD;
procedure AddFadeMsg(
FadeType : Byte; //0 - message style, 1 - information style, 2 - warning style
FadeIcon : HICON; //icon in the top left corner of the window
FadeTitle : WideString;
FadeText : WideString;
TextCentered : Boolean; //if true then text will be centered inside window
NoAutoClose : Boolean; //if NoAutoClose is True then wnd will be always shown until user close it. Not recommended to set this param to True.
CloseTime_Sec: Integer;
pData : Integer
);
procedure AddSpecContact(var UniqID: DWord; HeightCnt: Integer = 19);
procedure RedrawSpecContact(UniqID: DWord);
procedure RemoveSpecContact(var UniqID: DWord);
function GetLang(ID: Word) : WideString;
procedure InfiumClose(itype: Word);
procedure SetChangeVolume;
procedure ShowContactMenu(pX, pY : Integer );
procedure SaveSelectedRadio;
procedure StationNext;
procedure StationPrev;
protected
procedure CreateParams (var Params: TCreateParams); override;
end;
var
frmQIPPlugin: TfrmQIPPlugin;
FadeMsgs : TStringList;
FadeMsgsClosing : TStringList;
implementation
uses General, uImage, Convs, UpdaterUnit, uLNG, HotKeyManager,
DateUtils, BassPlayer, u_lang_ids, u_qip_plugin, uIcon, Drawing,
uSuperReplace, uStatistics, uColors, uTheme, uEqualizer, uFileFolder, uINI,
clipbrd;
{$R *.dfm}
procedure TfrmQIPPlugin.CreateParams (var Params: TCreateParams);
begin
inherited;
with Params do begin
ExStyle := (ExStyle or WS_EX_TOOLWINDOW or WS_EX_NOACTIVATE);
end;
end;
procedure TfrmQIPPlugin.WMHotKey(var msg:TWMHotKey);
var
INI : TIniFile;
begin
if msg.HotKey = 8801 then
FBassPlayer.PlayStopRadio
else if msg.HotKey = 8802 then
begin
Player_Volume := Player_Volume + 5;
if Player_Volume > 100 then
Player_Volume := 100;
SetChangeVolume;
end
else if msg.HotKey = 8803 then
begin
Player_Volume := Player_Volume - 5;
if Player_Volume < 0 then
Player_Volume := 0;
SetChangeVolume;
end
else if msg.HotKey = 8804 then
begin
if Player_Mute = False then
Player_Mute := True
else
Player_Mute := False;
SetChangeVolume;
end
else if msg.HotKey = 8805 then
begin
StationNext();
end
else if msg.HotKey = 8806 then
begin
StationPrev();
end
else if msg.HotKey = 8807 then // Enable/Disable XStatus
begin
EnDisXStatus(-1);
end;
end;
procedure TfrmQIPPlugin.FormClose(Sender: TObject; var Action: TCloseAction);
begin
// Unload_BASSDLL;
end;
procedure TfrmQIPPlugin.FormCreate(Sender: TObject);
begin
FadeMsgs := TStringList.Create;
FadeMsgs.Clear;
FadeMsgsClosing := TStringList.Create;
FadeMsgsClosing.Clear;
Stations := TStringList.Create;
Stations.Clear;
Playlist := TStringList.Create;
Playlist.Clear;
DataImportExport := TStringList.Create;
DataImportExport.Clear;
EqualizerPreset := TStringList.Create;
EqualizerPreset.Clear;
PluginSkin.MenuIcons := TStringList.Create;
PluginSkin.MenuIcons.Clear;
PluginSkin.OptionsIcons := TStringList.Create;
PluginSkin.OptionsIcons.Clear;
DTFormatDATETIME.DateSeparator := '-';
DTFormatDATETIME.TimeSeparator := ':';
DTFormatDATETIME.ShortDateFormat := 'YYYY-MM-DD';
DTFormatDATETIME.ShortTimeFormat := 'HH:MM:SS';
DTFormatDATETIME.LongDateFormat := 'YYYY-MM-DD'' ''HH:MM:SS';
FBassPlayer := TfrmBassPlayer.Create(nil);
// FBassPlayer.Show;
FBassPlayer.Height := 0;
FBassPlayer.Width := 0;
SetWindowPos(FBassPlayer.Handle,HWND_BOTTOM,0,0,0,0, SWP_NOACTIVATE {or SWP_SHOWWINDOW} or SWP_NOMOVE or SWP_NOSIZE);
end;
procedure TfrmQIPPlugin.CreateControls;
begin
//
end;
procedure TfrmQIPPlugin.FreeControls;
var RepMsg : TPluginMessage;
Repl_XStatus : TReplXStatus;
xRP : Boolean;
begin
xRP := False;
try
if Radio_Playing=True then
begin
xRP := True;
FBassPlayer.PlayStopRadio
end;
except
end;
try
if xRP = True then
begin
if (ActXstatusNum=11) or (XStatus_Type = 2) then
begin
if Radio_Playing=True then
begin
//FwStatus and FwDescription have to be class members or global variables to stay in memory because we return PWideChar
if Stations.Count - 1 >= Radio_StationID then
begin
Repl_XStatus.Station := TStation(Stations.Objects[Radio_StationID]).Name;
Repl_XStatus.Genre := TStation(Stations.Objects[Radio_StationID]).Genre;
if TStation(Stations.Objects[Radio_StationID]).Streams.Count - 1 >= Radio_StreamID then
Repl_XStatus.Format := TStream(TStation(Stations.Objects[Radio_StationID]).Streams.Objects[Radio_StreamID]).Format;
Repl_XStatus.Language := TStation(Stations.Objects[Radio_StationID]).Language;
Repl_XStatus.StationWeb := TStation(Stations.Objects[Radio_StationID]).URL;
end;
FwStatus := ReplXStatus(XStatus_Title,Repl_XStatus);// 'Listenig radio:'; //max xstatus text length = 20 chars
if Stations.Count - 1 < Radio_StationID then
FwDescription := '' //max description text length = 512 chars
else
FwDescription := ReplXStatus(XStatus_Text,Repl_XStatus); //TSLStation(Stations.Objects[Radio_StationID]).Name; //max description text length = 512 chars
end
else
begin
FwStatus := LastXStatusText ; {''; } //max xstatus text length = 20 chars
FwDescription := LastXStatusDescription; {'';} //max description text length = 512 chars
end;
{Plugin msg to update xstatus}
RepMsg.Msg := PM_PLUGIN_XSTATUS_UPD;
{ WParam is number of xstatus picture in Core/Xstatuses/xstatuses.ini, if 0 then xstatus pic will be removed}
{When changing music track you can change xstatus picture number, it will cauz all clients to request your new
xstatus value, but better to make it optional, because it can be bothering for remote users}
if (Radio_Playing=False) And (XStatus_Type = 2) then
RepMsg.WParam := LastXStatusNumber { 0 }// Xstatus - not
else
RepMsg.WParam := 11; // Xstatus - Music
RepMsg.LParam := LongInt(PWideChar(FwStatus));
RepMsg.NParam := LongInt(PWideChar(FwDescription));
{when plugin sending msg to qip core it have to add self dllhandle, else your msg will be ignored}
RepMsg.DllHandle := DllHandle;
{send message to qip core. !!! Dont change xtatus too often, it can cauz disconnect}
FPluginSvc.OnPluginMessage(RepMsg);
{================================================================}
end;
end;
except
end;
try
if bBassLoadLibLoaded = True then
FBassPlayer.BASSPlayer_AllFree;
finally
end;
try
UnregisterHotKey(QIPPlugin.Handle, 8801);
except
end;
try
UnregisterHotKey(QIPPlugin.Handle, 8802);
except
end;
try
UnregisterHotKey(QIPPlugin.Handle, 8803);
except
end;
try
UnregisterHotKey(QIPPlugin.Handle, 8804);
except
end;
try
UnregisterHotKey(QIPPlugin.Handle, 8805);
except
end;
try
UnregisterHotKey(QIPPlugin.Handle, 8806);
except
end;
try
UnregisterHotKey(QIPPlugin.Handle, 8807);
except
end;
try
if Assigned(FBassPlayer) then FreeAndNil(FBassPlayer);
except
end;
try
if Assigned(FAbout) then FreeAndNil(FAbout);
except
end;
try
if Assigned(FEqualizer) then FreeAndNil(FEqualizer);
except
end;
try
if Assigned(FFastAddStation) then FreeAndNil(FFastAddStation);
except
end;
try
if Assigned(FEditStations) then FreeAndNil(FEditStations);
except
end;
try
if Assigned(FInfo) then FreeAndNil(FInfo);
except
end;
try
if Assigned(FOptions) then FreeAndNil(FOptions);
except
end;
try
if Assigned(FRecording) then FreeAndNil(FRecording);
except
end;
try
if Assigned(FVolume) then FreeAndNil(FVolume);
except
end;
end;
procedure TfrmQIPPlugin.LoadPluginOptions;
var
PlugMsg1: TPluginMessage;
QipColors : pQipColors;
begin
PlugMsg1.Msg := PM_PLUGIN_GET_NAMES;
PlugMsg1.DllHandle := DllHandle;
FPluginSvc.OnPluginMessage(PlugMsg1);
if Boolean(PlugMsg1.Result) then
begin
Account_DisplayName := PWideChar(PlugMsg1.WParam);
Account_ProfileName := PWideChar(PlugMsg1.LParam);
end;
Account_FileName := Account_ProfileName;
// Profile path
PlugMsg1.Msg := PM_PLUGIN_GET_PROFILE_DIR;
PlugMsg1.DllHandle := DllHandle;
FPluginSvc.OnPluginMessage(PlugMsg1);
if Boolean(PlugMsg1.Result) then
begin
ProfilePath := PWideChar(PlugMsg1.WParam) + PLUGIN_NAME + '\';;
end;
PlugMsg1.Msg := PM_PLUGIN_GET_COLORS_FONT;
PlugMsg1.DllHandle := DllHandle;
FPluginSvc.OnPluginMessage(PlugMsg1);
//get results
{ wFontName := PWideChar(PlugMsg1.WParam);
iFontSize := PlugMsg1.LParam;}
QipColors := pQipColors(PlugMsg1.NParam);
QIP_Colors := QipColors^;
CheckFolder( ProfilePath, False );
tmrStart.Enabled := True;
end;
procedure TfrmQIPPlugin.miContactMenu_CopySongNameClick(Sender: TObject);
var
A: array[0..65000] of char;
Repl_XStatus : TReplXStatus;
sCopyText : WideString;
begin
if (Stations.Count - 1 < Radio_StationID) AND (Radio_StationID <> -1) then
else
begin
Repl_XStatus.Station := TStation(Stations.Objects[Radio_StationID]).Name;
Repl_XStatus.Genre := TStation(Stations.Objects[Radio_StationID]).Genre;
if (TStation(Stations.Objects[Radio_StationID]).Streams.Count - 1 >= Radio_StreamID) AND (Radio_StreamID <> -1) then
Repl_XStatus.Format := TStream(TStation(Stations.Objects[Radio_StationID]).Streams.Objects[Radio_StreamID]).Format;
Repl_XStatus.Language := TStation(Stations.Objects[Radio_StationID]).Language;
Repl_XStatus.StationWeb := TStation(Stations.Objects[Radio_StationID]).URL;
sCopyText := ReplXStatus('%song%',Repl_XStatus);
StrPCopy(A, sCopyText );
Clipboard.SetTextBuf(A);
end;
end;
procedure TfrmQIPPlugin.miContactMenu_EditStationsClick(Sender: TObject);
begin
OpenEditStations;
end;
procedure TfrmQIPPlugin.miContactMenu_EqualizerClick(Sender: TObject);
begin
OpenEqualizer;
end;
procedure TfrmQIPPlugin.miContactMenu_FastAddStationClick(Sender: TObject);
begin
OpenFastAddStation;
end;
procedure TfrmQIPPlugin.miContactMenu_FormatsClick(Sender: TObject);
begin
if Sender <> miContactMenu_Formats then
begin
// Radio_StationID := (Sender as TMenuItem).Tag;
Radio_StreamID := (Sender as TMenuItem).Tag;
if SaveLastStream = True then
TStation(Stations.Objects[Radio_StationID]).DefaultStream := Radio_StreamID;
SaveSelectedRadio;
if Radio_Playing = True then
begin
FBassPlayer.PlayStopRadio;
Application.ProcessMessages;
FBassPlayer.PlayStopRadio;
end;
RedrawSpecContact(UniqContactId);
end;
end;
procedure TfrmQIPPlugin.miContactMenu_InformationsClick(Sender: TObject);
begin
OpenInfo;
end;
procedure TfrmQIPPlugin.miContactMenu_OnOffClick(Sender: TObject);
begin
FBassPlayer.PlayStopRadio;
end;
procedure TfrmQIPPlugin.MeasureMenu(Sender: TObject;
ACanvas: TCanvas; var Width, Height: Integer);
begin
Menu_MeasureMenu(Sender, ACanvas, Width, Height);
end;
procedure TfrmQIPPlugin.DrawMenu(Sender: TObject;
ACanvas: TCanvas; ARect: TRect; Selected: Boolean);
begin
Menu_DrawMenu(Sender, ACanvas, ARect, Selected);
end;
procedure TfrmQIPPlugin.miContactMenu_OptionsClick(Sender: TObject);
begin
OpenOptions;
end;
procedure TfrmQIPPlugin.miContactMenu_RecordingClick(Sender: TObject);
begin
OpenRecording;
end;
procedure TfrmQIPPlugin.miContactMenu_StationsClick(Sender: TObject);
begin
if Sender <> miContactMenu_Stations then
begin
Radio_StationID := (Sender as TMenuItem).Tag;
Radio_StreamID := TStation(Stations.Objects[Radio_StationID]).DefaultStream;
SaveSelectedRadio;
if Radio_Playing = True then
begin
FBassPlayer.PlayStopRadio;
Application.ProcessMessages;
FBassPlayer.PlayStopRadio;
end;
RedrawSpecContact(UniqContactId);
end;
end;
procedure TfrmQIPPlugin.miContactMenu_VolumeClick(Sender: TObject);
begin
OpenVolume;
end;
procedure TfrmQIPPlugin.SavePluginOptions;
var
INI : TIniFile;
begin
INIGetProfileConfig(INI);
if Assigned(Stations) then
begin
if Radio_StationID > Stations.Count - 1 then
//dodelat
else
begin
INIWriteStringUTF8(INI, 'Conf', 'StationID', TStation(Stations.Objects[ Radio_StationID ]).Name );
end;
INIWriteInteger(INI, 'Conf', 'StreamID', Radio_StreamID );
end;
INIFree(INI);
end;
procedure TfrmQIPPlugin.ShowPluginOptions;
begin
OpenOptions;
end;
procedure OldSetToNewPLugin(INI: TINIFile);
var
S: TextFile;
Rec: TSearchRec;
pom: String;
idx: Integer;
INI2: TINIFile;
begin
if (UTF82WideString(INIReadStringUTF8(INI, 'Plugin', 'Version', PluginVersion)) >= '0.6.1') and (UTF82WideString(INIReadStringUTF8(INI, 'Plugin', 'Version', PluginVersion)) <= '0.6.1.99 beta') then
begin
INIGetProfileConfig(INI2);
pom := INI2.ReadString('Equalizer', 'Values', '') + ', ';
for idx := 10 to FrequencyCount do
pom := pom + '0, ';
Delete(pom, Length(pom) - 1, 2); // smazání poslední mezery s èárkou
INI2.WriteString('Equalizer', 'Values', pom);
INIFree(INI2);
end;
if (UTF82WideString(INIReadStringUTF8(INI, 'Plugin', 'Version', PluginVersion)) >= '0.6.0') and (UTF82WideString(INIReadStringUTF8(INI, 'Plugin', 'Version', PluginVersion)) <= '0.6.0 beta 8') then
begin
CopyFileIfExists(PluginDllPath+Account_FileName+'.ini',PluginDllPath + 'Profiles\' + Account_FileName + '\config.ini');
CopyFileIfExists(PluginDllPath+'statistic_'+Account_FileName+'.ini',PluginDllPath + 'Profiles\' + Account_FileName + '\statistic.ini');
CopyFileIfExists(PluginDllPath+'stations.ftx',PluginDllPath + 'Profiles\' + Account_FileName + '\stations.ftx');
DeleteFileIfExists(PluginDllPath+Account_FileName+'.ini');
DeleteFileIfExists(PluginDllPath+'statistic_'+Account_FileName+'.ini');
DeleteFileIfExists(PluginDllPath+'stations.ftx');
DeleteFileIfExists(PluginDllPath+'Skins\FMtune Big\skin.ini');
DeleteFileIfExists(PluginDllPath+'Skins\FMtune Big\graph.dll');
RemoveFolderIfExists(PluginDllPath+'Skins\FMtune Big');
INIGetProfileConfig(INI2);
INI2.DeleteKey('Conf', 'ScrollText');
INIFree(INI2);
end;
if (UTF82WideString(INIReadStringUTF8(INI, 'Plugin', 'Version', PluginVersion)) < '0.6.0') then
begin
DeleteFileIfExists(PluginDllPath+'Skins\FMtune\error.ico');
DeleteFileIfExists(PluginDllPath+'Skins\FMtune\icon.ico');
DeleteFileIfExists(PluginDllPath+'Skins\FMtune\pause.ico');
DeleteFileIfExists(PluginDllPath+'Skins\FMtune\play.ico');
DeleteFileIfExists(PluginDllPath+'Skins\FMtune\record.ico');
DeleteFileIfExists(PluginDllPath+'Skins\FMtune\stop.ico');
DeleteFileIfExists(PluginDllPath+'Skins\FMtune Big\error.ico');
DeleteFileIfExists(PluginDllPath+'Skins\FMtune Big\icon.ico');
DeleteFileIfExists(PluginDllPath+'Skins\FMtune Big\pause.ico');
DeleteFileIfExists(PluginDllPath+'Skins\FMtune Big\play.ico');
DeleteFileIfExists(PluginDllPath+'Skins\FMtune Big\record.ico');
DeleteFileIfExists(PluginDllPath+'Skins\FMtune Big\stop.ico');
DeleteFileIfExists(PluginDllPath+'Skins\FMtune Big\skin.ini');
RemoveFolderIfExists(PluginDllPath+'Skins\FMtune Big');
DeleteFileIfExists(PluginDllPath+'Skins\iSimple\error.ico');
DeleteFileIfExists(PluginDllPath+'Skins\iSimple\icon.ico');
DeleteFileIfExists(PluginDllPath+'Skins\iSimple\pause.ico');
DeleteFileIfExists(PluginDllPath+'Skins\iSimple\play.ico');
DeleteFileIfExists(PluginDllPath+'Skins\iSimple\record.ico');
DeleteFileIfExists(PluginDllPath+'Skins\iSimple\record2.ico');
DeleteFileIfExists(PluginDllPath+'Skins\iSimple\stop.ico');
DeleteFileIfExists(PluginDllPath+'Skins\iSimple\sound.ico');
DeleteFileIfExists(PluginDllPath+'icon.ico');
pom := '';
pom := pom + INIReadStringUTF8(INI, 'Equalizer', 'f70', '0');
INI.DeleteKey('Equalizer', 'f70');
pom := pom + ', ' + INIReadStringUTF8(INI, 'Equalizer', 'f180', '0');
INI.DeleteKey('Equalizer', 'f180');
pom := pom + ', ' + INIReadStringUTF8(INI, 'Equalizer', 'f320', '0');
INI.DeleteKey('Equalizer', 'f320');
pom := pom + ', ' + INIReadStringUTF8(INI, 'Equalizer', 'f600', '0');
INI.DeleteKey('Equalizer', 'f600');
pom := pom + ', ' + INIReadStringUTF8(INI, 'Equalizer', 'f1k', '0');
INI.DeleteKey('Equalizer', 'f1k');
pom := pom + ', ' + INIReadStringUTF8(INI, 'Equalizer', 'f3k', '0');
INI.DeleteKey('Equalizer', 'f3k');
pom := pom + ', ' + INIReadStringUTF8(INI, 'Equalizer', 'f6k', '0');
INI.DeleteKey('Equalizer', 'f6k');
pom := pom + ', ' + INIReadStringUTF8(INI, 'Equalizer', 'f12k', '0');
INI.DeleteKey('Equalizer', 'f12k');
pom := pom + ', ' + INIReadStringUTF8(INI, 'Equalizer', 'f14k', '0');
INI.DeleteKey('Equalizer', 'f14k');
pom := pom + ', ' + INIReadStringUTF8(INI, 'Equalizer', 'f16k', '0');
INI.DeleteKey('Equalizer', 'f16k');
INIWriteStringUTF8(INI, 'Equalizer', 'Values', pom);
INIWriteStringUTF8(INI, 'Conf', 'Skin', 'FMtune');
INI.DeleteKey('Conf', 'Language');
INI.EraseSection('Plugin');
if FindFirst(QIPInfiumPath + 'Profiles\*.*', faDirectory, Rec) = 0 then
begin
While FindNext(Rec) = 0 do
begin
if ExtractFileExt(Rec.Name) <> '' then
Rec.Name := '';
if Rec.Name = '' then
else if Rec.Name = '.' then
else if Rec.Name = '..' then
else
begin
{if not DirectoryExists(PluginDllPath + 'Profiles\'+Copy(Rec.Name, 1, Length(Rec.Name))) then
CreateDir(PluginDllPath + 'Profiles\'+Copy(Rec.Name, 1, Length(Rec.Name)));}
CheckFolder( PluginDllPath + 'Profiles\'+Copy(Rec.Name, 1, Length(Rec.Name)) , False );
CopyFileIfExists(PluginDllPath+'FMtune.ini',PluginDllPath + 'Profiles\' + Copy(Rec.Name, 1, Length(Rec.Name)) + '\config.ini');
CopyFileIfExists(PluginDllPath+'stations.ftx',PluginDllPath + 'Profiles\' + Copy(Rec.Name, 1, Length(Rec.Name)) + '\stations.ftx');
//showmessage ( PluginDllPath+ Copy(Rec.Name, 1, Length(Rec.Name)) + '.ini' ) ;
// AssignFile(S,{PChar(}PluginDllPath+ Copy(Rec.Name, 1, Length(Rec.Name)) + '.ini'{)});
// Reset(S);
// WriteLn(S,'; Code page: UTF-8');
// WriteLn(S);
// CloseFile(S);
end;
end;
end;
FindClose(Rec);
DeleteFileIfExists(PluginDllPath+'stations.ftx');
AssignFile(S,PluginDllPath + PLUGIN_NAME + '.ini');
Rewrite(S);
CloseFile(S);
end;
if (UTF82WideString(INIReadStringUTF8(INI, 'Plugin', 'Version', PluginVersion)) <= '0.6.3') then
begin
INI.EraseSection('Proxy');
INIGetProfileConfig(INI2);
if INIReadBool(INI2, 'Proxy', 'Enabled', false) = false then
INIWriteInteger(INI2, 'Proxy', 'Mode', 0)
else
INIWriteInteger(INI2, 'Proxy', 'Mode', 2);
INIDeleteKey(INI2, 'Proxy', 'Enabled');
INIFree(INI2);
end;
// --- pøevod aktuální profilu, pøevádí vdy pokud nebylo pøevedeno
if DirectoryExists( PluginDllPath + 'Profiles\' + Account_FileName ) = True then
begin
//presunout do noveho umisteni
MoveFileIfExists( PluginDllPath + 'Profiles\' + Account_FileName + '\config.ini', ProfilePath + 'config.ini' );
MoveFileIfExists( PluginDllPath + 'Profiles\' + Account_FileName + '\statistic.ini', ProfilePath + 'statistic.ini' );
MoveFileIfExists( PluginDllPath + 'Profiles\' + Account_FileName + '\stations.ftx', ProfilePath + 'stations.ftx' );
//odstrani starou slozku profilu
RemoveFolderIfExists( PluginDllPath + 'Profiles\' + Account_FileName );
//odstrani slozku starou Profiles (pouze pokud je prazdna)
RemoveFolderIfExists( PluginDllPath + 'Profiles' );
end;
end;
procedure TfrmQIPPlugin.tmrDrawTimer(Sender: TObject);
var bCntRedraw : Boolean;
Repl_XStatus : TReplXStatus;
begin
tmrDraw.Enabled := False;
bCntRedraw := False;
if SpecCntInfoTextScroll = True then
begin
Dec(SpecCntInfoTextX, 1);
if SpecCntInfoTextX = -SpecCntInfoTextWidth then
SpecCntInfoTextX := SpecCntInfoMaxWidth;
bCntRedraw := True;
end;
if SpecCntInfo2TextScroll = True then
begin
Dec(SpecCntInfo2TextX, 1);
if SpecCntInfo2TextX = -SpecCntInfo2TextWidth then
SpecCntInfo2TextX := SpecCntInfo2MaxWidth;
bCntRedraw := True;
end;
//showmessage( inttostr(Radio_StationID ) +#13 + inttostr(Radio_StreamID ) );
if (Stations.Count - 1 >= Radio_StationID) AND (Radio_StationID <> -1) then
begin
//if (Radio_StationID <> -1) AND (Radio_StreamID <> -1) then
if (TStation(Stations.Objects[Radio_StationID]).Streams.Count - 1 >= Radio_StreamID) AND (Radio_StreamID <> -1) then
begin
Repl_XStatus.Station := TStation(Stations.Objects[Radio_StationID]).Name;
Repl_XStatus.Genre := TStation(Stations.Objects[Radio_StationID]).Genre;
Repl_XStatus.Format := TStream(TStation(Stations.Objects[Radio_StationID]).Streams.Objects[Radio_StreamID]).Format;
Repl_XStatus.Language := TStation(Stations.Objects[Radio_StationID]).Language;
Repl_XStatus.StationWeb := TStation(Stations.Objects[Radio_StationID]).URL;
end
end
else
begin
Repl_XStatus.Station := '';
Repl_XStatus.Genre := '';
Repl_XStatus.Format := '';
Repl_XStatus.Language := '';
Repl_XStatus.StationWeb := '';
end;
if ReplXStatus(SpecCntLine1Text,Repl_XStatus) <> SpecCntInfoText then
bCntRedraw := True;
if ReplXStatus(SpecCntLine2Text,Repl_XStatus) <> SpecCntInfo2Text then
bCntRedraw := True;
if bCntRedraw = True then
RedrawSpecContact(UniqContactId);
tmrDraw.Enabled := True;
end;
procedure TfrmQIPPlugin.tmrStartTimer(Sender: TObject);
var
hLibraryPics : THandle;
F : TextFile;
FName : WideString;
INI : TINIFile;
sXStatusTitle,sXStatusText, sPopupText, sL1Text, sL2Text: WideString;
PlugMsg1: TPluginMessage;
idx : Integer;
// iMod, iKey: Word;
// hIndex: Integer;
sColor: WideString;
NetParams : pNetParams;
begin
tmrStart.Enabled := False;
StatisticsRadioTime := 0; // nastavení pøehrávání rádia na 0
(* //// Tato vìc je prozatím k nièemu :D ale vypadá hezky :D
osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo) ;
if GetVersionEx(osVerInfo) then;
if osVerInfo.dwMajorVersion < 6 then
pmContactMenu.Images := ImageList1
else
pmContactMenu.Images := nil;
///////////////*)
(* // Tvorba sloky profilù, pokud neexistují
if not DirectoryExists(PluginDllPath + 'Profiles') then
begin
CreateDir(PluginDllPath + 'Profiles');
end;
if not DirectoryExists(PluginDllPath + 'Profiles\'+Account_FileName) then
begin
CreateDir(PluginDllPath + 'Profiles\'+Account_FileName);
end;
// ---*)
INI := TiniFile.Create(PluginDllPath + PLUGIN_NAME + '.ini');
// Pøevod starého nastavení uivatelù pro novou verzi
OldSetToNewPlugin(INI);
INIWriteStringUTF8(INI, 'Plugin', 'Version', PluginVersion);
INIWriteStringUTF8(INI, 'SDK', 'Version', IntToStr(QIP_SDK_VER_MAJOR) + '.' + IntToStr(QIP_SDK_VER_MINOR));
//// Naètení barev
sColor := INIReadStringUTF8(INI, 'Colors', '1', 'F0F0F0'); //frmBgColor = $00F0F0F0;//$00FFEEDD;
frmBgColor := RGB( StrToInt('$' + Copy(sColor,1,2)),
StrToInt('$' + Copy(sColor,3,2)),
StrToInt('$' + Copy(sColor,5,2)));
INIWriteStringUTF8(INI, 'Colors', '1', sColor);
INIFree(INI);
INIGetProfileConfig(INI);
PluginLanguage := INIReadStringUTF8(INI, 'Conf', 'Language', '<default>');
CheckUpdates := INIReadBool(INI, 'Conf', 'CheckUpdates', True );
CheckUpdatesInterval := INIReadInteger(INI, 'Conf', 'CheckUpdatesInterval', 6);
CheckBetaUpdates := INIReadBool(INI, 'Conf', 'CheckBetaUpdates', False );
// pokud je plugin v testovací fázi, jsou zapnuty beta aktualizace
if Trim(PLUGIN_VER_BETA) <> '' then
begin
CheckBetaUpdates := True;
end;
PluginTheme.Name := INIReadStringUTF8(INI, 'Conf', 'Skin', 'FMtune');
OpenTheme;
sNStationID := INIReadStringUTF8(INI, 'Conf', 'StationID', '');