-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathuMain.pas
3224 lines (3102 loc) · 118 KB
/
uMain.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 uMain;
{******************************************************************************}
{* Main Form Unit *}
{* Revolutionary Confederation of Anarcho Syndicalists *}
{* Written by: black.rabbit 2011-2012 *}
{******************************************************************************}
interface
{$I 'std.inc'}
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, ExtCtrls,
ComCtrls, StdCtrls, Forms, Menus, ActnList, StdActns, Dialogs,
ToolWin,
sSkinManager, sSkinProvider,
ImgList, acAlphaImageList, jpeg, pngimage, acPNG,
sPanel, sPageControl, sTabControl, sGroupBox, sScrollBox, sStatusBar, acCoolBar,
Buttons, sBitBtn, sSpeedButton, sCheckBox,
sEdit, sMemo, sRichEdit, RxRichEd,
Mask, sMaskEdit, sTooledit, sSpinEdit,
sCustomComboEdit, sComboBoxes, sComboBox,
sLabel, sColorSelect, sTreeView, sListView, sGauge,
{ utils }
DateUtils, Utils, Strings, VarRecs, Versions, EClasses,
DllThreads,
{ kernel }
Kernel, ProtoClasses, CryptoClasses, MetaClasses, ParaClasses,
HypoClasses, HyperClasses,
{ engine }
Engine,
{ SQLite }
SQLite3, SQLite3DLL, SQLiteTable3;
{ èêîíêè ëîãà ïî÷òû }
const
pckDefault = 0;
pckEmpty = 1;
pckFull = 2;
pckTest = 3;
pckError = 4;
pckSend = 5;
type
TfmMain = class (TForm)
SkinProvider: TsSkinProvider;
SkinBlack: TsSkinManager;
imgTabs: TsAlphaImageList;
imgIconsSmall: TsAlphaImageList;
imgIcons: TsAlphaImageList;
imgTree: TsAlphaImageList;
imgSmiles: TsAlphaImageList;
imgSmilesOct31: TsAlphaImageList;
imgSmilesAdvanced: TsAlphaImageList;
imgQuotes: TsAlphaImageList;
imgUsers: TsAlphaImageList;
imgMail: TsAlphaImageList;
{ actions }
lstActions: TActionList;
actHelp: TAction;
actAbout: TAction;
actAdd: TAction;
actEdit: TAction;
actDelete: TAction;
{ text }
actTextCopy: TEditCopy;
actTextCut: TEditCut;
actTextPaste: TEditPaste;
actTextDelete: TEditDelete;
actTextSelectAll: TEditSelectAll;
{ user }
actSaveUser: TAction;
{ users }
actAddUser: TAction;
actEditUser: TAction;
actDeleteUser: TAction;
actSynchronizeUser: TAction;
{ forum }
actAddCategorie: TAction;
actEditCategorie: TAction;
actDeleteCategorie: TAction;
actQuoteMessage: TAction;
actAddMessage: TAction;
actEditMessage: TAction;
actDeleteMessage: TAction;
actRefreshMessage: TAction;
actPrev: TAction;
actNext: TAction;
actRefresh: TAction;
actURL: TAction;
actHome: TAction;
{ menu }
{ text }
mnTextPopup: TPopupMenu;
mnItemCopy: TMenuItem;
mnItemCut: TMenuItem;
mnItemPaste: TMenuItem;
mnItemDelete: TMenuItem;
mnItemBreak: TMenuItem;
mnItemSelectAll: TMenuItem;
{ categories }
mnCategoriesPopup: TPopupMenu;
mnItemAddCtg: TMenuItem;
mnItemEditCtg: TMenuItem;
mnItemDeleteCtg: TMenuItem;
{ messages }
mnMessagesPopup: TPopupMenu;
mnItemEditMessage: TMenuItem;
mnItemDeleteMessage: TMenuItem;
{ users }
mnUsersPopup: TPopupMenu;
mnItemAddUser: TMenuItem;
mnItemEditUser: TMenuItem;
mnItemDeleteUser: TMenuItem;
mnItemUpdateForum: TMenuItem;
{ status bar }
StatusBar: TsStatusBar;
Gauge: TsGauge;
{ left panel }
btLeftPanel: TsSpeedButton;
pnlLeft: TsPanel;
imLeftRed: TImage;
imgArrowRed: TImage;
pnlMenu: TsPanel;
btCopy: TsSpeedButton;
btPaste: TsSpeedButton;
btCut: TsSpeedButton;
btClear: TsSpeedButton;
btSelectAll: TsSpeedButton;
btAdd: TsSpeedButton;
btEdit: TsSpeedButton;
btDelete: TsSpeedButton;
btHelp: TsSpeedButton;
btAbout: TsSpeedButton;
{ tabs }
tabs: TsPageControl;
{ forum }
tbForum: TsTabSheet;
pnlNavigation: TsPanel;
btNext: TsSpeedButton;
btRefresh: TsSpeedButton;
btPrev: TsSpeedButton;
btHome: TsSpeedButton;
edURL: TsEdit;
btURL: TsSpeedButton;
bxForum: TsScrollBox;
Tree: TsTreeView;
pnlReply: TsPanel;
pnlReplyMenu: TsPanel;
btBold: TsSpeedButton;
btUnderline: TsSpeedButton;
btItalic: TsSpeedButton;
btKey: TsSpeedButton;
btReply: TsSpeedButton;
btCancelMessage: TsSpeedButton;
edReply: TRxRichEdit;
btColor: TPanel;
btSmile: TsSpeedButton;
{ users }
tbUsers: TsTabSheet;
bxUsers: TsScrollBox;
lstUsers: TsTreeView;
pnlCryptoMessage: TsPanel;
edCryptoMessage: TsRichEdit;
btEncrypt: TsSpeedButton;
btDecrypt: TsSpeedButton;
{ user }
{ - profile }
tbUser: TsTabSheet;
btSaveUser: TsSpeedButton;
actRefreshUser: TAction;
btCancelUser: TsSpeedButton;
bxUser: TsScrollBox;
pnlProfile: TsPanel;
imgProfile: TImage;
lbProfile: TsWebLabel;
pnlUserPic: TsPanel;
imgUserPic: TImage;
UserPic: TsFilenameEdit;
lbUserDescription: TsLabel;
UserDescription: TsRichEdit;
lbUserMail: TsLabel;
UserMail: TsEdit;
lbUserMailPassword: TsLabel;
UserMailPassword: TsMaskEdit;
lbUserIP: TsLabel;
UserIP: TsEdit;
lbUserPort: TsLabel;
UserPort: TsSpinEdit;
UserSex: TsComboBoxEx;
UserBirthday: TsDateEdit;
lbUserSMTPHost: TsLabel;
UserSMTPHost: TsEdit;
lbUserSMTPPort: TsLabel;
UserSMTPPort: TsSpinEdit;
lbUserPOP3Host: TsLabel;
UserPOP3Host: TsEdit;
lbUserPOP3Port: TsLabel;
UserPOP3Port: TsSpinEdit;
cbxUserAutoTLS: TsCheckBox;
cbxUserFullSSL: TsCheckBox;
{ - crypto }
pnlCryptoProfile: TsPanel;
pnlCryptoLabels: TsPanel;
lbUserRandom: TsLabel;
lbUserAsymmetric: TsLabel;
lbUserSymmetric: TsLabel;
lbUserMode: TsLabel;
lbUserHash: TsLabel;
lbUserPublicKey: TsLabel;
pnlCryptoControls: TsPanel;
btRandomTest: TsSpeedButton;
btAsymmetricTest: TsSpeedButton;
btSymmetricTest: TsSpeedButton;
btHashTest: TsSpeedButton;
UserRandom: TsComboBox;
UserPublicKey: TsRichEdit;
UserAsymmetric: TsComboBox;
UserSymmetric: TsComboBox;
UserMode: TsComboBox;
UserHash: TsComboBox;
{ - proxy }
pnlUseProxy: TsPanel;
cbxUserUseProxy: TsCheckBox;
pnlProxy: TsPanel;
lbUserProxyIP: TsLabel;
lbUserProxyPort: TsLabel;
lbUserProxyLogin: TsLabel;
lbUserProxyPassword: TsLabel;
lbUserProxyProtocol: TsLabel;
UserProxyIP: TsEdit;
UserProxyPort: TsSpinEdit;
UserProxyLogin: TsEdit;
UserProxyPassword: TsMaskEdit;
UserProxyProtocol: TsComboBox;
{ - connection }
pnlConnection: TsPanel;
lbUserTimeOut: TsLabel;
lbUserTimeOutDesc: TsLabel;
UserTimeOut: TsSpinEdit;
{ mail }
tbMail: TsTabSheet;
tmMail: TTimer;
lstMail: TsListView;
{ actions }
procedure actAboutExecute (Sender: TObject);
procedure actHelpExecute (Sender: TObject);
procedure actAddExecute (Sender: TObject);
procedure actAddUpdate (Sender: TObject);
procedure actAddCategorieExecute (Sender: TObject);
procedure actAddCategorieUpdate (Sender: TObject);
procedure actAddMessageExecute (Sender: TObject);
procedure actAddMessageUpdate (Sender: TObject);
procedure actAddUserExecute (Sender: TObject);
procedure actAddUserUpdate (Sender: TObject);
procedure actEditExecute (Sender: TObject);
procedure actEditUpdate (Sender: TObject);
procedure actEditCategorieExecute (Sender: TObject);
procedure actEditCategorieUpdate (Sender: TObject);
procedure actEditMessageExecute (Sender: TObject);
procedure actEditMessageUpdate (Sender: TObject);
procedure actEditUserExecute (Sender: TObject);
procedure actEditUserUpdate (Sender: TObject);
procedure actDeleteExecute (Sender: TObject);
procedure actDeleteUpdate (Sender: TObject);
procedure actDeleteCategorieExecute (Sender: TObject);
procedure actDeleteCategorieUpdate (Sender: TObject);
procedure actDeleteMessageExecute (Sender: TObject);
procedure actDeleteMessageUpdate (Sender: TObject);
procedure actDeleteUserExecute (Sender: TObject);
procedure actDeleteUserUpdate (Sender: TObject);
procedure actSaveUserUpdate (Sender: TObject);
procedure actSaveUserExecute (Sender: TObject);
procedure actRefreshUserUpdate (Sender: TObject);
procedure actRefreshUserExecute (Sender: TObject);
procedure actRefreshMessageExecute (Sender: TObject);
procedure actRefreshMessageUpdate (Sender: TObject);
procedure actRefreshExecute (Sender: TObject);
procedure actRefreshUpdate (Sender: TObject);
procedure actURLExecute (Sender: TObject);
procedure actURLUpdate (Sender: TObject);
procedure actHomeExecute (Sender: TObject);
procedure actNextExecute (Sender: TObject);
procedure actNextUpdate (Sender: TObject);
procedure actPrevExecute (Sender: TObject);
procedure actPrevUpdate (Sender: TObject);
procedure actQuoteMessageExecute (Sender: TObject);
procedure actQuoteMessageUpdate (Sender: TObject);
procedure actSynchronizeUserUpdate (Sender: TObject);
procedure actSynchronizeUserExecute (Sender: TObject);
{ events }
procedure tmMailTimer (Sender: TObject);
procedure FormCloseQuery (Sender: TObject; var CanClose: Boolean);
procedure FormResize (Sender: TObject);
procedure FormKeyDown (Sender: TObject; var Key: Word; Shift: TShiftState);
procedure tabsChange (Sender: TObject);
procedure TreeAdvancedCustomDrawItem (Sender: TCustomTreeView;
Node: TTreeNode;
State: TCustomDrawState;
Stage: TCustomDrawStage;
var PaintImages, DefaultDraw: Boolean);
procedure TreeChange (Sender: TObject; Node: TTreeNode);
procedure TreeDblClick (Sender: TObject);
procedure lstUsersAdvancedCustomDrawItem (Sender: TCustomTreeView;
Node: TTreeNode;
State: TCustomDrawState;
Stage: TCustomDrawStage;
var PaintImages, DefaultDraw: Boolean);
procedure lstUsersChange (Sender: TObject; Node: TTreeNode);
procedure lstUsersDblClick (Sender: TObject);
procedure lstMailAdvancedCustomDrawItem (Sender: TCustomListView;
Item: TListItem;
State: TCustomDrawState;
Stage: TCustomDrawStage;
var DefaultDraw: Boolean);
procedure btEncryptClick (Sender: TObject);
procedure btDecryptClick (Sender: TObject);
procedure btLeftPanelClick (Sender: TObject);
procedure btBoldClick (Sender: TObject);
procedure btUnderlineClick (Sender: TObject);
procedure btItalicClick (Sender: TObject);
procedure btKeyClick (Sender: TObject);
procedure btColorMouseDown (Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure btSmileMouseDown (Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure UserPicAfterDialog (Sender: TObject; var Name: string; var Action: Boolean);
procedure btRandomTestClick (Sender: TObject);
procedure btAsymmetricTestClick (Sender: TObject);
procedure btSymmetricTestClick (Sender: TObject);
procedure btHashTestClick (Sender: TObject);
procedure cbxUserUseProxyClick (Sender: TObject);
private
ActiveLeftButton : TObject;
public
procedure OnButtonMove (Sender: TObject; Shift: TShiftState; X,Y: Integer);
procedure OnBackGroundMove (Sender: TObject; Shift: TShiftState; X,Y: Integer);
procedure OnLeftButtonMove (Sender: TObject; Shift: TShiftState; X,Y: Integer);
procedure OnRichEditMouseDown (Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure OnEditChange (Sender: TObject);
procedure OnControlMouseWheel (Sender: TObject;
Shift: TShiftState;
WheelDelta: Integer;
MousePos: TPoint;
var Handled: Boolean);
{ non visual }
public
class procedure _raise (anArgs: array of const;
const anEGUID: String = ''); overload; virtual;
class procedure _raise (anArgs: array of const;
anEGUID: array of const); overload; virtual;
private
f_CurrentSmiles: TsAlphaImageList;
f_DBFileName: String;
f_DB: TSQLiteDatabase;
f_Threads: TDllThreads;
f_MailThreads: TDllThreads;
f_CurrCtgKeyHash: Hex;
f_CurrCtgID: TID;
f_CurrMsgKeyHash: Hex;
f_CurrMsgID: TID;
f_CurrMsgTmp: TFrame;
f_EditMsgID: TID;
f_CurrUsrID: TID;
f_History: TStringList;
f_HistoryIndex: Integer;
protected
procedure GetURLData;
procedure GetUserData;
procedure GetCategoriesData;
procedure UnloadMessagesList;
procedure GetMessagesData;
procedure GetKeyWordsData;
procedure GetUsersData;
procedure GetMailData; overload;
procedure SetUserData;
procedure SetMailData; overload;
public
procedure UpdateMailData (const anUser: TUser); overload;
procedure SetMailData (const anObject: TMetaObject); overload;
public
function GetImgSmiles : TsAlphaImageList;
procedure GetData;
procedure SetData;
public
constructor Create (anOwner: TComponent); override;
destructor Destroy; override;
public
procedure WriteStatus (const aMessage: String); overload;
procedure WriteStatus (const aMessage: String;
aParams: array of const); overload;
procedure Progress (const aCount: Integer); overload;
procedure Progress (const aCount: Integer;
const aMessage: String); overload;
procedure Progress (const aCount: Integer;
const aMessage: String;
aParams: array of const); overload;
public
procedure MailLog (const aSender: String;
const aReceiver: String;
const aMessage: String;
const anImageIndex: Integer = pckDefault); overload;
procedure MailLog (const aSender: String;
const aReceiver: String;
const aMessage: String;
aParams: array of const;
const anImageIndex: Integer = pckDefault); overload;
public
property CurrentSmiles: TsAlphaImageList read f_CurrentSmiles write f_CurrentSmiles;
property DBFileName: String read f_DBFileName;
property DB: TSQLiteDatabase read f_DB write f_DB;
property Threads: TDllThreads read f_Threads write f_Threads;
property MailThreads: TDllThreads read f_MailThreads write f_MailThreads;
property CurrCtgKeyHash: Hex read f_CurrCtgKeyHash write f_CurrCtgKeyHash;
property CurrCtgID: TID read f_CurrCtgID write f_CurrCtgID;
property CurrMsgKeyHash: Hex read f_CurrMsgKeyHash write f_CurrMsgKeyHash;
property CurrMsgID: TID read f_CurrMsgID write f_CurrMsgID;
property CurrMsgTmp: TFrame read f_CurrMsgTmp write f_CurrMsgTmp;
property EditMsgID: TID read f_EditMsgID write f_EditMsgID;
property CurrUsrID: TID read f_CurrUsrID write f_CurrUsrID;
property History: TStringList read f_History write f_History;
property HistoryIndex: Integer read f_HistoryIndex write f_HistoryIndex;
end;
const
pnlLeftMenuButton = 0; { êíîïêà óïðàâëåíè ëåâûì ìåíþ }
pnlProgress = 1; { ïîëîñà çàãðóçêè }
pnlStatusText = 2; { òåêñòîâàÿ ÷àñòü ïàíåëè ñîñòîÿíèÿ }
resourcestring
ERR_TFMMAIN_CREATE = 'Îøèáêà ñîçäàíèÿ ãëàâíîãî îêíà ïðîãðàììû!';
ERR_TFMMAIN_DESTROY = 'Îøèáêà óíè÷òîæåíèÿ ãëàâíîãî îêíà ïðîãðàììû!';
ERR_TFMMAIN_WRITE_STATUS = 'Îøèáêà îòîáðàæåíèÿ ñòàòóñà!';
ERR_TFMMAIN_PROGRESS = 'Îøèáêà îòîáðàæåíèÿ ïðîãðåññà!';
ERR_TFMMAIN_WRITE_LOG = 'Îøèáêà âåäåíèÿ ëîãà!';
ERR_TFMMAIN_CLOSE_QUERY = 'Îøèáêà çàêðûòèÿ ãëàâíîãî îêíà ïðîãðàììû!';
ERR_TFMMAIN_TABS_CHANGE = 'Îøèáêà ïåðåêëþ÷åíèÿ âêëàäîê!';
ERR_TFMMAIN_RESIZE = 'Îøèáêà èçìåíåíèÿ ðàçìåðà ãëàâíîãî îêíà ïðîãðàììû!';
ERR_TFMMAIN_DRAW = 'Îøèáêà îòðèñîâêè ãëàâíîãî îêíà ïðîãðàììû!';
ERR_TFMMAIN_ACTION_EXECUTE = 'Îøèáêà âûïîëíåíèÿ äåéñòâèÿ!';
ERR_TFMMAIN_ACTION_UPDATE = 'Îøèáêà îáðàáîòêè ñòàòóñà äåéñòâèÿ!';
ERR_TFMMAIN_GET_SMILES = 'Îøèáêà ïîëó÷åíèÿ íàáîðà ñìàéëîâ!';
ERR_TFMMAIN_GET_DATA = 'Îøèáêà ÷òåíèÿ äàííûõ!';
ERR_TFMMAIN_GET_USER_DATA = 'Îøèáêà ÷òåíèÿ ïîëüçîâàòåëüñêèõ äàííûõ!';
ERR_TFMMAIN_GET_KEYWORDS_DATA = 'Îøèáêà ïîèñêà ïî êëþ÷åâûì ñëîâàì!';
ERR_TFMMAIN_GET_CATEGORIES_DATA = 'Îøèáêà çàãðóçêè äåðåâà êàòåãîðèé!';
ERR_TFMMAIN_GET_MESSAGES_DATA = 'Îøèáêà çàãðóçêè ñïèñêà ñîîáùåíèé!';
ERR_TFMMAIN_GET_MESSAGE_DATA = 'Íå óäàëîñü çàãðóçèòü ñîîáùåíèå : id = %d';
ERR_TFMMAIN_UNLOAD_MESSAGES_LIST = 'Îøèáêà âûãðóçêè ñïèñêà ñîîáùåíèé!';
ERR_TFMMAIN_GET_USERS_DATA = 'Îøèáêà çàãðóçêè ñïèñêà ïîëüçîâàòåëåé!';
ERR_TFMMAIN_GET_URL_DATA = 'Îøèáêà çàãðóçêè URL!';
ERR_TFMMAIN_GET_MAIL_DATA = 'Îøèáêà çàãðóçêè ïî÷òû!';
ERR_TFMMAIN_GET_COLOR = 'Îøèáêà âûáîðà öâåòà!';
ERR_TFMMAIN_GET_SMILE = 'Îøèáêà âûáîðà ñìàéëà!';
ERR_TFMMAIN_SET_TEXT_ATTRIBUTES = 'Îøèáêà óñòàíîâêè òåêñòîâûõ àòðèáóòîâ!';
ERR_TFMMAIN_SET_DATA = 'Îøèáêà çàïèñè äàííûõ!';
ERR_TFMMAIN_SET_USER_DATA = 'Îøèáêà çàïèñè ïîëüçîâàòåëüñêèõ äàííûõ!';
ERR_TFMMAIN_SET_CATEGORIES_DATA = 'Îøèáêà ñîõðàíåíèÿ äåðåâà êàòåãîðèé!';
ERR_TFMMAIN_SET_USERS_DATA = 'Îøèáêà ñîõðàíåíèÿ ñïèñêà ïîëüçîâàòåëåé!';
ERR_TFMMAIN_SET_MAIL_DATA = 'Îøèáêà îòïðàâêè ïî÷òû!';
ERR_TFMMAIN_UPDATE_MAIL_DATA = 'Îøèáêà ôîðìèðîâàíèÿ ïàêåòîâ îáíîâëåíèé!';
ERR_TFMMAIN_INVALID_OBJECT = 'Íåêîððåêòíûé îáúåêò!';
ERR_TFMMAIN_INVALID_OBJECT_CLASS = 'Íåêîððåêòíûé òèï ïàêåòà: "%s"!';
var
MainForm: TfmMain;
implementation
{$R *.dfm}
uses
{ crypto }
Crypto,
{ bb-code }
BBCode,
{ dialogs }
DialogClasses, uProtoDialog, uMetaDialog, uWizardDialog,
uLoginDialog, uRegisterDialog,
uRandomTestDialog, uAsymmetricTestDialog, uSymmetricTestDialog, uHashTestDialog,
uCategorieDialog,
{ templates }
uTmpMessage,
{ loaders }
uMessagesLoader,
uCategoriesLoader,
uKeyWordsLoader,
uUsersLoader,
{ http }
{$IFDEF HTTP}
HTTPServer,
HTTPClient,
uHTTPServer,
uHTTPCLient,
{$ENDIF HTTP}
{ smtp/pop3 }
{$IFDEF SMTP_POP3}
SMTPClient,
POP3Client,
uSMTPClient,
uPOP3Client,
{$ENDIF SMTP_POP3}
{ scanners }
uPackagesScanner,
{ constructors }
uPackagesConstructor;
class procedure TfmMain._raise (anArgs: array of const;
const anEGUID: String = '');
begin
raise EClass.Create ( _([self],anArgs), anEGUID );
end;
class procedure TfmMain._raise (anArgs: array of const;
anEGUID: array of const);
begin
raise EClass.Create ( _([self],anArgs), anEGUID );
end;
constructor TfmMain.Create (anOwner: TComponent);
begin
try
inherited Create (anOwner);
{ DB }
f_DBFileName := DATABASE_FILE_NAME;
f_DB := TSQLiteDatabase.Create (f_DBFileName);
if Assigned (User) then
User.DB := DB;
{ threads }
f_Threads := TDllThreads.Create;
f_MailThreads := TDllThreads.Create;
{ history }
f_History := TStringList.Create;
f_HistoryIndex := -1;
{ version }
Caption := Format ('%s - %s',[ ProductName, User.Login ]);
{ mouse wheel }
OnMouseWheel := OnControlMouseWheel;
{ left menu panel }
pnlMenu.OnMouseMove := OnBackGroundMove;
btCopy.OnMouseMove := OnLeftButtonMove;
btCut.OnMouseMove := OnLeftButtonMove;
btPaste.OnMouseMove := OnLeftButtonMove;
btClear.OnMouseMove := OnLeftButtonMove;
btSelectAll.OnMouseMove := OnLeftButtonMove;
btAdd.OnMouseMove := OnLeftButtonMove;
btEdit.OnMouseMove := OnLeftButtonMove;
btDelete.OnMouseMove := OnLeftButtonMove;
btHelp.OnMouseMove := OnLeftButtonMove;
btAbout.OnMouseMove := OnLeftButtonMove;
{ forum }
pnlNavigation.OnMouseMove := OnBackGroundMove;
btPrev.OnMouseMove := OnButtonMove;
btNext.OnMouseMove := OnButtonMove;
btRefresh.OnMouseMove := OnButtonMove;
btURL.OnMouseMove := OnButtonMove;
btHome.OnMouseMove := OnButtonMove;
btReply.OnMouseMove := OnButtonMove;
btCancelMessage.OnMouseMove := OnButtonMove;
edReply.OnMouseDown := OnRichEditMouseDown;
edReply.MaxLength := 0; //MAX_MESSAGE_LENGTH;
btBold.OnMouseMove := OnButtonMove;
btUnderline.OnMouseMove := OnButtonMove;
btItalic.OnMouseMove := OnButtonMove;
btKey.OnMouseMove := OnButtonMove;
btColor.OnMouseMove := OnButtonMove;
btSmile.OnMouseMove := OnButtonMove;
{ user }
lbProfile.Caption := Format ('ïðîôèëü: %s',[User.Login]);
btSaveUser.OnMouseMove := OnButtonMove;
btCancelUser.OnMouseMove := OnButtonMove;
UserMail.OnChange := OnEditChange;
UserMailPassword.OnChange := OnEditChange;
UserIP.OnChange := OnEditChange;
UserPort.OnChange := OnEditChange;
UserDescription.OnChange := OnEditChange;
UserSex.OnChange := OnEditChange;
UserBirthday.OnChange := OnEditChange;
UserPic.OnChange := OnEditChange;
UserRandom.OnChange := OnEditChange;
//UserAsymmetric.OnChange := OnEditChange;
//UserSymmetric.OnChange := OnEditChange;
//UserMode.OnChange := OnEditChange;
//UserHash.OnChange := OnEditChange;
//UserPublicKey.OnChange := OnEditChange;
cbxUserUseProxy.OnClick := OnEditChange;
UserProxyIP.OnChange := OnEditChange;
UserProxyPort.OnChange := OnEditChange;
UserProxyLogin.OnChange := OnEditChange;
UserProxyPassword.OnChange := OnEditChange;
UserProxyProtocol.OnChange := OnEditChange;
UserTimeOut.OnChange := OnEditChange;
UserSMTPHost.OnChange := OnEditChange;
UserSMTPPort.OnChange := OnEditChange;
UserPOP3Host.OnChange := OnEditChange;
UserPOP3Port.OnChange := OnEditChange;
cbxUserAutoTLS.OnClick := OnEditChange;
cbxUserFullSSL.OnClick := OnEditChange;
{ users }
pnlCryptoMessage.OnMouseMove := OnBackGroundMove;
edCryptoMessage.OnMouseMove := OnButtonMove;
btEncrypt.OnMouseMove := OnButtonMove;
btDecrypt.OnMouseMove := OnButtonMove;
{ mail }
tmMail.Interval := User.TimeOut * 10;
tmMail.Enabled := TRUE;
{ active page }
tabs.TabIndex := 0;
except on E: Exception do
_raise (['Create',ERR_TFMMAIN_CREATE,E],
['{92249C2F-F939-4BE2-96AC-EE224A71FEDF}']);
end;
end;
destructor TfmMain.Destroy;
begin
try
FreeAndNil (f_History);
MailThreads.Terminate;
FreeAndNil (f_MailThreads);
Threads.Terminate;
FreeAndNil (f_Threads);
UnLoadCategoriesTree (Tree.Items);
UnloadMessagesList;
UnLoadUsersList (lstUsers.Items);
FreeAndNil (f_DB);
inherited Destroy;
except on E: Exception do
_raise (['Destroy',ERR_TFMMAIN_DESTROY,E],
['{A24E525F-6632-44B9-95FF-19E412D76D19}']);
end;
end;
procedure TfmMain.FormKeyDown (Sender: TObject; var Key: Word; Shift: TShiftState);
const
VK_B = 66;
VK_U = 85;
VK_I = 73;
VK_K = 75;
begin
{ Ctrl + Left -- prev }
if ( Key = VK_LEFT )
and ( ssCtrl in Shift )
and not ( ssAlt in Shift )
and not ( ssShift in Shift )
and actPrev.Enabled then
actPrev.Execute
{ Ctrl + Right -- next }
else if ( Key = VK_RIGHT )
and ( ssCtrl in Shift )
and not ( ssAlt in Shift )
and not ( ssShift in Shift )
and actNext.Enabled then
actNext.Execute
{ Enter -- go to url }
else if ( Key = VK_RETURN )
and not ( ssCtrl in Shift )
and not ( ssAlt in Shift )
and not ( ssShift in Shift )
and ( ActiveControl = edURL )
and actURL.Enabled then
actURL.Execute
{ Enter -- expand / collapse categorie }
else if ( Key = VK_RETURN )
and not ( ssCtrl in Shift )
and not ( ssAlt in Shift )
and not ( ssShift in Shift )
and ( ActiveControl = Tree )
and Assigned (Tree.Selected) then
begin
if Tree.Selected.Expanded then
Tree.Selected.Collapse (FALSE)
else
Tree.Selected.Expand (FALSE)
end
{ Ctrl + Enter -- load categorie messages }
else if ( Key = VK_RETURN )
and ( ssCtrl in Shift )
and not ( ssAlt in Shift )
and not ( ssShift in Shift )
and ( ActiveControl = Tree )
and Assigned (Tree.Selected)
and ( CurrCtgID > 0 )
and actURL.Enabled then
actURL.Execute
{ Ctrl + B -- bold }
else if ( Key = VK_B )
and ( ssCtrl in Shift )
and not ( ssAlt in Shift )
and not ( ssShift in Shift )
and ( ActiveControl = edReply )
and btBold.Enabled then
btBold.Click
{ Ctrl + U -- underline }
else if ( Key = VK_U )
and ( ssCtrl in Shift )
and not ( ssAlt in Shift )
and not ( ssShift in Shift )
and ( ActiveControl = edReply )
and btUnderline.Enabled then
btUnderline.Click
{ Ctrl + I -- italic }
else if ( Key = VK_I )
and ( ssCtrl in Shift )
and not ( ssAlt in Shift )
and not ( ssShift in Shift )
and ( ActiveControl = edReply )
and btItalic.Enabled then
btItalic.Click
{ Ctrl + K -- keyword }
else if ( Key = VK_K )
and ( ssCtrl in Shift )
and not ( ssAlt in Shift )
and not ( ssShift in Shift )
and ( ActiveControl = edReply )
and btItalic.Enabled then
btKey.Click
end;
procedure TfmMain.FormCloseQuery (Sender: TObject; var CanClose: Boolean);
begin
try
CanClose := FALSE;
try
WriteStatus ('Çàâåðøåíèå ðàáîòû...');
Gauge.Progress := 0;
Gauge.MaxValue := 6;
Progress (1,'Çàâåðøåíèå ïîòîêîâ...');
MailThreads.Terminate;
Threads.Terminate;
Progress (1,'Âûãðóçêà ðàçäåëîâ...');
UnLoadCategoriesTree (Tree.Items);
Progress (1,'Âûãðóçêà ñïèñêà êîíòàêòîâ...');
UnLoadUsersList (lstUsers.Items);
{ Óäàëÿåì ïàêåòû, ïðèøåäøèå íàì: îáðàáîòàííûå è îòâåðãíóòûå.
Ïàêåòîâ, ïðåäíàçíà÷åííûõ íàì, ñî ñòàòóñàìè "ñîçäàí" èëè "îòïðàâëåí"
áûòü íå äîëæíî, íî íà âñÿêèé ñëó÷àé ìû óäàëÿåì è òàêèå ïàêåòû.
Îñòàâëÿåì òîëüêî ïàêåòû ñî ñòàòóñîì "ïîëó÷åí",
êîòîðûå íåîáõîäèìî îáðàáîòàòü â äàëüíåéøåì. }
Progress (1,'Óäàëåíèå îáðàáîòàííûõ è îòâåðãíóòûõ ïàêåòîâ...');
TPackages.Delete (DB,[ _([]),
_([]),
_([USER_KEY_HASH]),
_([USER_ID]),
_([]),
_([PACKAGE_REJECTED_STATUS_ID,
PACKAGE_EXECUTED_STATUS_ID,
PACKAGE_CREATED_STATUS_ID,
PACKAGE_SENDED_STATUS_ID]),
_([]) ]);
{ Óäàëÿåì ïàêåòû, îòïðàâëåííûå íàìè.
Îòâåðãíóòûå ïîëó÷àòåëåì ïàêåòû ìû äîëæíû óäàëÿòü ñðàçó,
íî íà âñÿêèé ñëó÷àé óäàëèì è èõ.
Ñîçäàííûõ íàìè ïàêåòîâ ñî ñòàòóñàìè "ïîëó÷åí" èëè "èñïîëíåí"
áûòü íå äîëæíî, íî íà âñÿêèé ñëó÷àé ìû óäàëÿåì è òàêèå ïàêåòû.
Îñòàâëÿåì òîëüêî ïàêåòû ñî ñòàòóñîì "ñîçäàí",
êîòîðûå íåîáõîäèìî îòïðàâèòü â äàëüíåéøåì. }
Progress (1,'Óäàëåíèå îòïðàâëåííûõ ïàêåòîâ...');
TPackages.Delete (DB,[ _([]),
_([USER_KEY_HASH]),
_([]),
_([USER_ID]),
_([]),
_([PACKAGE_SENDED_STATUS_ID,
PACKAGE_REJECTED_STATUS_ID,
PACKAGE_RECEIVED_STATUS_ID,
PACKAGE_EXECUTED_STATUS_ID]),
_([]) ]);
Progress (1,'Ñæàòèå áàçû äàííûõ...');
DB.Compress;
finally
CanClose := TRUE;
Halt;
end;
except on E: Exception do
_raise (['FormCloseQuery',ERR_TFMMAIN_CLOSE_QUERY,E],
['{E0F33354-384D-4CB9-87E3-2CAA2700C1C3}']);
end;
end;
function TfmMain.GetImgSmiles : TsAlphaImageList;
var
y : WORD;
m : WORD;
d : WORD;
begin
Result := NIL;
try
if not Assigned (CurrentSmiles) then
begin
DecodeDate (now,y,m,d);
if ( ( m = 10 ) and ( d >= 29 ) ) or
( ( m = 11 ) and ( d <= 3 ) ) then
CurrentSmiles := imgSmilesOct31
else
CurrentSmiles := imgSmiles;
end;
Result := CurrentSmiles;
except on E: Exception do
_raise (['GetImgSmiles',ERR_TFMMAIN_GET_SMILES,E],
['{B9BC23FD-E15B-4250-B27E-8F52EF1EEBE9}']);
end;
end;
procedure TfmMain.GetData;
var
URI : String;
I : Integer;
begin
try
{ start mail services }
if ( MailThreads.Count = 0 ) and Assigned (User) then
GetMailData;
{ categories }
if ( tabs.ActivePage = tbForum ) and Tree.Visible then
GetCategoriesData
{ messages }
else if ( tabs.ActivePage = tbForum ) and not Tree.Visible and ( CurrCtgID > 0 ) then
GetMessagesData
{ users }
else if ( tabs.ActivePage = tbUsers ) and lstUsers.Visible then
GetUsersData
{ user }
else if ( tabs.ActivePage = tbUser ) then
GetUserData
{ mail }
else if ( tabs.ActivePage = tbMail ) then
GetMailData;
{ history }
URI := Trim (edURL.Text);
try
if not isEmpty ( Trim (URI) ) then
begin
{ î÷èùàåì èñòîðèþ ïîñëå òåêóùåãî ñîñòîÿíèÿ }
for I := HistoryIndex + 1 to History.Count - 1 do
History.Delete (I);
{ äîáàâëÿåì íîâîå ñîñòîÿíèå â èñòîðèþ }
if ( History.Count = 0 ) or ( History.Strings [HistoryIndex] <> URI ) then
begin
History.Add (URI);
HistoryIndex := History.Count - 1;
end;
end
finally
_FillChar ( URI, Length (URI), $00 );
end;
except on E: Exception do
_raise (['GetData',ERR_TFMMAIN_GET_DATA,E],
['{A43EB1D3-5F53-4D5A-84AF-E0188ED290EF}']);
end;
end;
procedure TfmMain.SetData;
begin
try
{ categories }
if ( tabs.ActivePage = tbForum ) and Tree.Visible then
//SetCategoriesData
{ messages }
else if ( tabs.ActivePage = tbForum ) and not Tree.Visible and ( CurrCtgID > 0 ) then
//SetMessagesData
{ users }
else if ( tabs.ActivePage = tbUsers ) and lstUsers.Visible then
//SetUsersData
{ user }
else if ( tabs.ActivePage = tbUser ) then
SetUserData
{ mail }
else if ( tabs.ActivePage = tbMail ) then
//SetMailsData;
except on E: Exception do
_raise (['SetData',ERR_TFMMAIN_SET_DATA,E],
['{BD9738EB-8F22-4333-85A0-1ECFDC9D4AA6}']);
end;
end;
procedure TfmMain.GetUserData;
var
I : Integer;
begin
try
WriteStatus ('Çàãðóçêà ïðîôèëÿ...');
Gauge.Progress := 0;
Gauge.MaxValue := 30;
Progress (1,'Çàâåðøåíèå ïîòîêîâ...');
Threads.Terminate;
Progress (1,'Î÷èñòêà ñòðîêè àäðåñà...');
edURL.Text := 'crypto://user/';
if ( GetTabStatus (tabUser) = tbsLoaded ) then
begin
Progress (Gauge.MaxValue,'...');
Exit;
end;
Progress (1,'ëîãèí...');
lbProfile.Caption := Format ('ïðîôèëü: %s',[User.Login]);
Progress (1,'àâàòàð...');
imgUserPic.Picture.Assign (User.Pic.Picture);
imgUserPic.Repaint;
Progress (1,'ýë.ïî÷òà...');
UserMail.Text := User.EMail;
Progress (1,'ïàðîëü ê ýë.ïî÷òå...');
UserMailPassword.Text := User.EMailPassword;
Progress (1,'ip-àäðåñ...');
UserIP.Text := User.IP;
Progress (1,'ïîðò...');
UserPort.Value := User.Port;
Progress (1,'ëè÷íàÿ èíôîðìàöèÿ...');
UserDescription.Clear;
UserDescription.Text := User.Description;
Progress (1,'ëè÷íàÿ èíôîðìàöèÿ...');
UserSex.ItemIndex := User.Sex;
Progress (1,'ëè÷íàÿ èíôîðìàöèÿ...');
UserBirthday.Date := User.Birthday;
Progress (1,'ãåíåðàòîð ñëó÷àéíûõ ÷èñåë...');
with UserRandom.Items do
try
BeginUpdate;
Clear;
for I := Low (RANDOM_TYPE_STRING) + 1 to High (RANDOM_TYPE_STRING) do
Add (RANDOM_TYPE_STRING [I]);
UserRandom.Text := User.Crypto.genRandom;
UserRandom.ReadOnly := FALSE;
finally
EndUpdate;
end;
Progress (1,'àñèììåòðè÷íûé øèôð...');
with UserAsymmetric.Items do
try
BeginUpdate;
Clear;
for I := Low (PKCRYPTO_TYPE_STRING) + 1 to High (PKCRYPTO_TYPE_STRING) do
Add (PKCRYPTO_TYPE_STRING [I]);
UserAsymmetric.Text := User.Crypto.algAsymmetric;
UserAsymmetric.ReadOnly := TRUE;
finally
EndUpdate;
end;
Progress (1,'ñèììåòðè÷íûé øèôð...');
with UserSymmetric.Items do
try
BeginUpdate;
Clear;
for I := Low (CRYPTO_TYPE_STRING) + 1 to High (CRYPTO_TYPE_STRING) do
Add (CRYPTO_TYPE_STRING [I]);
UserSymmetric.Text := User.Crypto.algSymmetric;
UserSymmetric.ReadOnly := TRUE;
finally
EndUpdate;
end;
Progress (1,'ðåæèì ñèììåòðè÷íîãî øèôðîâàíèÿ...');
with UserMode.Items do
try
BeginUpdate;
Clear;
for I := Low (CRYPTO_MODE_STRING) + 1 to High (CRYPTO_MODE_STRING) do
Add (CRYPTO_MODE_STRING [I]);
UserMode.Text := User.Crypto.modeSymmetric;
UserMode.ReadOnly := TRUE;
finally
EndUpdate;
end;
Progress (1,'õýø-ôóíêöèÿ...');
with UserHash.Items do
try
BeginUpdate;
Clear;
for I := Low (HASH_TYPE_STRING) + 1 to High (HASH_TYPE_STRING) do
Add (HASH_TYPE_STRING [I]);
UserHash.Text := User.Crypto.algHash;
UserHash.ReadOnly := TRUE;
finally
EndUpdate;
end;
Progress (1,'ïóáëè÷íûé êëþ÷...');
UserPublicKey.Text := User.PublicKey;
Progress (1,'èñïîëüçîâàíèå proxy...');
cbxUserUseProxy.Checked := User.UseProxy and
( User.ProxyIP <> '' ) and
( User.ProxyPort > 0 );
pnlProxy.Visible := cbxUserUseProxy.Checked;
Progress (1,'proxy ip-àäðåñ...');
UserProxyIP.Text := User.ProxyIP;
Progress (1,'proxy ïîðò...');
UserProxyPort.Value := User.ProxyPort;
Progress (1,'proxy ëîãèí...');
UserProxyLogin.Text := User.ProxyLogin;
Progress (1,'proxy ïàðîëü...');
UserProxyPassword.Text := User.ProxyPassword;
Progress (1,'proxy ïðîòîêîë...');
with UserProxyProtocol.Items do
try
BeginUpdate;
Clear;
{$IFDEF HTTP}
Add ('HTTP');
{$ENDIF HTTP}
Add ('SOCKS4');
Add ('SOCKS5');
if isEmpty (User.ProxyProtocol) then
UserProxyProtocol.Text := UserProxyProtocol.Items [0]