-
Notifications
You must be signed in to change notification settings - Fork 0
/
MediaWikiApi.pas
3106 lines (2797 loc) · 124 KB
/
MediaWikiApi.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
{**************************************************************************************************}
{ }
{ Project JEDI }
{ }
{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); }
{ you may not use this file except in compliance with the License. You may obtain a copy of the }
{ License at http://www.mozilla.org/MPL/ }
{ }
{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF }
{ ANY KIND, either express or implied. See the License for the specific language governing rights }
{ and limitations under the License. }
{ }
{ The Original Code is MediaWikiApi.pas }
{ }
{ The Initial Developer of the Original Code is Florent Ouchet. }
{ Portions created by Florent Ouchet are Copyright Florent Ouchet. All rights reserved. }
{ }
{ Contributor(s): }
{ }
{**************************************************************************************************}
unit MediaWikiApi;
interface
// main documentation is located at http://www.mediawiki.org/wiki/API
uses
SysUtils,
Classes,
JclBase,
JclSimpleXml,
OverbyteIcsHttpProt,
OverbyteIcsWSocket,
MediaWikiUtils;
type
TMediaWikiRequest = (mwrLogin, mwrLogout,
mwrQuerySiteInfoGeneral, mwrQuerySiteInfoNamespaces, mwrQuerySiteInfoNamespaceAliases,
mwrQuerySiteInfoSpecialPageAliases, mwrQuerySiteInfoMagicWords, mwrQuerySiteInfoStatistics,
mwrQuerySiteInfoInterWikiMap, mwrQuerySiteInfoDBReplLag, mwrQuerySiteInfoUserGroups,
mwrQuerySiteInfoExtensions,
mwrQueryTokens,
mwrQueryUserInfoBlockInfo, mwrQueryUserInfoHasMsg, mwrQueryUserInfoGroups,
mwrQueryUserInfoRights, mwrQueryUserInfoChangeableGroups, mwrQueryUserInfoOptions,
mwrQueryUserInfoEditCount, mwrQueryUserInfoRateLimits,
mwrQueryMessages,
mwrQueryPageInfo, mwrQueryPageRevisionInfo, mwrQueryPageCategoryInfo,
mwrQueryPageLinkInfo, mwrQueryPageTemplateInfo, mwrQueryPageExtLinkInfo,
mwrQueryAllPageInfo, mwrQueryAllLinkInfo, mwrQueryAllCategoryInfo,
mwrQueryAllUserInfo, mwrQueryBackLinkInfo, mwrQueryBlockInfo, mwrQueryCategoryMemberInfo,
mwrEdit, mwrMove, mwrDelete, mwrDeleteRevision, mwrUpload, mwrUserMerge);
TMediaWikiRequests = set of TMediaWikiRequest;
const
MediaWikiExclusiveRequests: TMediaWikiRequests =
[mwrLogin, mwrLogout, mwrEdit, mwrMove, mwrDelete, mwrDeleteRevision, mwrUpload];
{$TYPEINFO ON}
type
TMediaWikiApi = class;
TMediaWikiCallback = procedure (Sender: TMediaWikiApi) of object;
TMediaWikiWarningCallback = procedure (Sender: TMediaWikiApi; const AInfo, AQuery: string; var Ignore: Boolean);
TMediaWikiErrorCallback = procedure (Sender: TMediaWikiApi; const AInfo, ACode: string; var Ignore: Boolean);
TMediaWikiXMLCallback = procedure (Sender: TMediaWikiApi; XML: TJclSimpleXML) of object;
TMediaWikiStringsCallback = procedure (Sender: TMediaWikiApi; AStrings: TStrings) of object;
TMediaWikiExtensionsCallback = procedure (Sender: TMediaWikiApi; const Extensions: TMediaWikiExtensions) of object;
TMediaWikiBooleanCallback = procedure (Sender: TMediaWikiApi; Value: Boolean) of object;
TMediaWikiIntegerCallback = procedure (Sender: TMediaWikiApi; Value: Integer) of object;
TMediaWikiRateLimitsCallback = procedure (Sender: TMediaWikiApi; const RateLimits: TMediaWikiRateLimits) of object;
TMediaWikiPageInfosCallback = procedure (Sender: TMediaWikiApi; const PageInfos: TMediaWikiPageInfos) of object;
TMediaWikiPageRevisionInfosCallback = procedure (Sender: TMediaWikiApi; const PageRevisionInfos: TMediaWikiPageRevisionInfos; const ContinueInfo: TMediaWikiContinueInfo) of object;
TMediaWikiRevisionRangeCallback = procedure (Sender: TMediaWikiApi; StartRevID, EndRevID: TMediaWikiID) of object;
TMediaWikiPageCategoryCallback = procedure (Sender: TMediaWikiApi; const PageCategoryInfos: TMediaWikiPageCategoryInfos; const ContinueInfo: TMediaWikiContinueInfo) of object;
TMediaWikiPageLinkCallback = procedure (Sender: TMediaWikiApi; const PageLinkInfos: TMediaWikiPageLinkInfos; const ContinueInfo: TMediaWikiContinueInfo) of object;
TMediaWikiPageTemplateCallback = procedure (Sender: TMediaWikiApi; const PageTemplateInfos: TMediaWikiPageTemplateInfos; const ContinueInfo: TMediaWikiContinueInfo) of object;
TMediaWikiPageExtLinkCallback = procedure (Sender: TMediaWikiApi; const PageExtLinkInfos: TMediaWikiPageExtLinkInfos; const ContinueInfo: TMediaWikiContinueInfo) of object;
TMediaWikiAllPageCallback = procedure (Sender: TMediaWikiApi; const AllPages: TMediaWikiAllPageInfos; const ContinueInfo: TMediaWikiContinueInfo) of object;
TMediaWikiAllLinkCallback = procedure (Sender: TMediaWikiApi; const AllLinks: TMediaWikiAllLinkInfos; const ContinueInfo: TMediaWikiContinueInfo) of object;
TMediaWikiAllCategoriesCallback = procedure (Sender: TMediaWikiApi; ACategories: TStrings; const ContinueInfo: TMediaWikiContinueInfo) of object;
TMediaWikiAllUserCallback = procedure (Sender: TMediaWikiApi; const AllUsers: TMediaWikiAllUserInfos; const ContinueInfo: TMediaWikiContinueInfo) of object;
TMediaWikiBackLinkCallback = procedure (Sender: TMediaWikiApi; const BackLinks: TMediaWikiBackLinkInfos; const ContinueInfo: TMediaWikiContinueInfo) of object;
TMediaWikiBlockCallback = procedure (Sender: TMediaWikiApi; const Blocks: TMediaWikiBlockInfos; const ContinueInfo: TMediaWikiContinueInfo) of object;
TMediaWikiCategoryMemberCallback = procedure (Sender: TMediaWikiApi; const CategoryMembers: TMediaWikiCategoryMemberInfos; const ContinueInfo: TMediaWikiContinueInfo) of object;
TMediaWikiEditCallback = procedure (Sender: TMediaWikiApi; const EditInfo: TMediaWikiEditInfo) of object;
TMediaWikiMoveCallback = procedure (Sender: TMediaWikiApi; const MoveInfo: TMediaWikiMoveInfo) of object;
TMediaWikiDeleteCallback = procedure (Sender: TMediaWikiApi; const DeleteInfo: TMediaWikiDeleteInfo) of object;
TMediaWikiDeleteRevisionCallback = procedure (Sender: TMediaWikiApi; const DeleteRevisionInfo: TMediaWikiDeleteRevisionInfo) of object;
TMediaWikiUploadCallback = procedure (Sender: TMediaWikiApi; const UploadInfo: TMediaWikiUploadInfo) of object;
TMediaWikiUserMergeCallback = procedure (Sender: TMediaWikiApi; const UserMergeInfo: TMediaWikiUserMergeInfo) of object;
TMediaWikiTokenValuesCallback = procedure (Sender: TMediaWikiApi; const Tokens: TMediaWikiTokenValues) of object;
TMediaWikiXMLRequestCallbacks = array [TMediaWikiRequest] of TMediaWikiXMLCallback;
TMediaWikiApi = class
// general stuff
private
FHttpsCli: TSslHttpCli;
FSslContext: TSslContext;
procedure OnCookieRcvd(Sender: TObject; const Data: String; var Accept: Boolean);
private
FSendStream: TMemoryStream;
FReceiveStream: TMemoryStream;
FRequestCallbacks: TMediaWikiXMLRequestCallbacks;
FQueryStrings: TStrings;
FPendingRequests: TMediaWikiRequests;
function GetReady: Boolean;
procedure RequestDone(Sender: TObject; RqType: THttpRequest; ErrCode: Word);
public
constructor Create;
destructor Destroy; override;
procedure CheckRequest(Request: TMediaWikiRequest);
procedure QueryInit;
property SendStream: TMemoryStream read FSendStream;
property ReceiveStream: TMemoryStream read FReceiveStream;
// synchronous post
function QueryExecute: AnsiString;
procedure QueryExecuteXML(XML: TJclSimpleXML);
// asynchronous post
procedure QueryExecuteAsync;
property PendingRequests: TMediaWikiRequests read FPendingRequests;
property Ready: Boolean read GetReady;
published
property HttpsCli: TSslHttpCli read FHttpsCli;
property SslContext: TSslContext read FSslContext;
// error handling
private
FIgnoreWarnings: Boolean;
FIgnoreErrors: Boolean;
FOnWarning: TMediaWikiWarningCallback;
FOnError: TMediaWikiErrorCallback;
procedure ProcessXMLWarning(const AInfo, AQuery: string);
procedure ProcessXMLError(const AInfo, ACode: string);
public
property IgnoreWarnings: Boolean read FIgnoreWarnings write FIgnoreWarnings;
property IgnoreErrors: Boolean read FIgnoreErrors write FIgnoreErrors;
property OnWarning: TMediaWikiWarningCallback read FOnWarning write FOnWarning;
property OnError: TMediaWikiErrorCallback read FOnError write FOnError;
//property OutputFormat: TMediaWikiOutputFormat;
// login stuff
private
FOnLoginDone: TMediaWikiCallback;
FLoginPassword: string;
FLoginResult: TMediaWikiLoginResult;
FLoginToken: string;
FLoginUserID: TMediaWikiID;
FLoginUserName: string;
procedure LoginParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
procedure LoginGetToken(Sender: TMediaWikiApi; const TokenValues: TMediaWikiTokenValues);
public
// synchronous login
function Login: TMediaWikiLoginResult; overload;
function Login(const lgName, lgPassword: string): TMediaWikiLoginResult; overload;
function Login(const lgName, lgPassword, lgToken: string): TMediaWikiLoginResult; overload;
function Login(const lgName, lgPassword, lgToken: string; OutputFormat: TMediaWikiOutputFormat): AnsiString; overload;
// asynchronous login
procedure LoginAsync; overload;
procedure LoginAsync(const lgName, lgPassword: string); overload;
procedure LoginAsync(const lgName, lgPassword, lgToken: string); overload;
property OnLoginDone: TMediaWikiCallback read FOnLoginDone write FOnLoginDone;
// login states
property LoginToken: string read FLoginToken write FLoginToken;
property LoginResult: TMediaWikiLoginResult read FLoginResult write FLoginResult;
property LoginUserID: TMediaWikiID read FLoginUserID write FLoginUserID;
published
property LoginUserName: string read FLoginUserName write FLoginUserName;
property LoginPassword: string read FLoginPassword write FLoginPassword;
// logout stuff
private
FOnLogoutDone: TMediaWikiCallback;
procedure LogoutParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
// synchronous login
procedure Logout; overload;
procedure Logout(const csrf: string); overload;
// asynchronous login
procedure LogoutAsync(const csrf: string);
property OnLogoutDone: TMediaWikiCallback read FOnLogoutDone write FOnLogoutDone;
// Meta information queries, site information, general
private
FOnQuerySiteInfoGeneralDone: TMediaWikiStringsCallback;
FQuerySiteInfoGeneralStrings: TStrings;
procedure QuerySiteInfoGeneralParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QuerySiteInfoGeneral(Infos: TStrings); overload;
function QuerySiteInfoGeneral(OutputFormat: TMediaWikiOutputFormat): AnsiString; overload;
procedure QuerySiteInfoGeneralAsync;
property OnQuerySiteInfoGeneralDone: TMediaWikiStringsCallback read FOnQuerySiteInfoGeneralDone write FOnQuerySiteInfoGeneralDone;
// Meta information queries, site information, namespaces: A list of all namespaces
private
FOnQuerySiteInfoNamespacesDone: TMediaWikiStringsCallback;
FQuerySiteInfoNamespacesStrings: TStrings;
procedure QuerySiteInfoNamespacesParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QuerySiteInfoNamespaces(Infos: TStrings); overload;
function QuerySiteInfoNamespaces(OutputFormat: TMediaWikiOutputFormat): AnsiString; overload;
procedure QuerySiteInfoNamespacesAsync;
property OnQuerySiteInfoNamespacesDone: TMediaWikiStringsCallback read FOnQuerySiteInfoNamespacesDone write FOnQuerySiteInfoNamespacesDone;
// Meta information queries, site information, namespacealiases: A list of all namespace aliases (MW 1.13+)
private
FOnQuerySiteInfoNamespaceAliasesDone: TMediaWikiStringsCallback;
FQuerySiteInfoNamespaceAliasesStrings: TStrings;
procedure QuerySiteInfoNamespaceAliasesParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QuerySiteInfoNamespaceAliases(Infos: TStrings); overload;
function QuerySiteInfoNamespaceAliases(OutputFormat: TMediaWikiOutputFormat): AnsiString; overload;
procedure QuerySiteInfoNamespaceAliasesAsync;
property OnQuerySiteInfoNamespaceAliasesDone: TMediaWikiStringsCallback read FOnQuerySiteInfoNamespaceAliasesDone write FOnQuerySiteInfoNamespaceAliasesDone;
// Meta information queries, site information, specialpagealiases: A list of all special page aliases (MW 1.13+)
private
FOnQuerySiteInfoSpecialPageAliasesDone: TMediaWikiStringsCallback;
FQuerySiteInfoSpecialPageAliasesStrings: TStrings;
procedure QuerySiteInfoSpecialPageAliasesParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QuerySiteInfoSpecialPageAliases(Infos: TStrings); overload;
function QuerySiteInfoSpecialPageAliases(OutputFormat: TMediaWikiOutputFormat): AnsiString; overload;
procedure QuerySiteInfoSpecialPageAliasesAsync;
property OnQuerySiteInfoSpecialPageAliasesDone: TMediaWikiStringsCallback read FOnQuerySiteInfoSpecialPageAliasesDone write FOnQuerySiteInfoSpecialPageAliasesDone;
// Meta information queries, site information, magicwords: A list of magic words and their aliases (MW 1.14+)
private
FOnQuerySiteInfoMagicWordsDone: TMediaWikiStringsCallback;
FQuerySiteInfoMagicWordsStrings: TStrings;
procedure QuerySiteInfoMagicWordsParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QuerySiteInfoMagicWords(Infos: TStrings); overload;
function QuerySiteInfoMagicWords(OutputFormat: TMediaWikiOutputFormat): AnsiString; overload;
procedure QuerySiteInfoMagicWordsAsync;
property OnQuerySiteInfoMagicWordsDone: TMediaWikiStringsCallback read FOnQuerySiteInfoMagicWordsDone write FOnQuerySiteInfoMagicWordsDone;
// Meta information queries, site information, statistics: Site statistics à la Special:Statistics (MW 1.11+)
private
FOnQuerySiteInfoStatisticsDone: TMediaWikiStringsCallback;
FQuerySiteInfoStatisticsStrings: TStrings;
procedure QuerySiteInfoStatisticsParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QuerySiteInfoStatistics(Infos: TStrings); overload;
function QuerySiteInfoStatistics(OutputFormat: TMediaWikiOutputFormat): AnsiString; overload;
procedure QuerySiteInfoStatisticsAsync;
property OnQuerySiteInfoStatisticsDone: TMediaWikiStringsCallback read FOnQuerySiteInfoStatisticsDone write FOnQuerySiteInfoStatisticsDone;
// Meta information queries, site information, interwikimap: A list of all interwiki prefixes and where they go (MW 1.11+)
private
FOnQuerySiteInfoInterWikiMapDone: TMediaWikiStringsCallback;
FQuerySiteInfoInterWikiMapStrings: TStrings;
procedure QuerySiteInfoInterWikiMapParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QuerySiteInfoInterWikiMap(Local: Boolean; Infos: TStrings); overload;
function QuerySiteInfoInterWikiMap(Local: Boolean; OutputFormat: TMediaWikiOutputFormat): AnsiString; overload;
procedure QuerySiteInfoInterWikiMapAsync(Local: Boolean);
property OnQuerySiteInfoInterWikiMapDone: TMediaWikiStringsCallback read FOnQuerySiteInfoInterWikiMapDone write FOnQuerySiteInfoInterWikiMapDone;
// Meta information queries, site information, dbrepllag: Get information about the database server with the highest replication lag (MW 1.11)
private
FOnQuerySiteInfoDBReplLagDone: TMediaWikiStringsCallback;
FQuerySiteInfoDBReplLagStrings: TStrings;
procedure QuerySiteInfoDBReplLagParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QuerySiteInfoDBReplLag(ShowAllDB: Boolean; Infos: TStrings); overload;
function QuerySiteInfoDBReplLag(ShowAllDB: Boolean; OutputFormat: TMediaWikiOutputFormat): AnsiString; overload;
procedure QuerySiteInfoDBReplLagAsync(ShowAllDB: Boolean);
property OnQuerySiteInfoDBReplLagDone: TMediaWikiStringsCallback read FOnQuerySiteInfoDBReplLagDone write FOnQuerySiteInfoDBReplLagDone;
// Meta information queries, site information, usergroups: A list of all user groups and their permissions (MW 1.13+)
private
FOnQuerySiteInfoUserGroupsDone: TMediaWikiStringsCallback;
FQuerySiteInfoUserGroupsStrings: TStrings;
procedure QuerySiteInfoUserGroupsParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QuerySiteInfoUserGroups(IncludeUserCount: Boolean; Infos: TStrings); overload;
function QuerySiteInfoUserGroups(IncludeUserCount: Boolean; OutputFormat: TMediaWikiOutputFormat): AnsiString; overload;
procedure QuerySiteInfoUserGroupsAsync(IncludeUserCount: Boolean);
property OnQuerySiteInfoUserGroupsDone: TMediaWikiStringsCallback read FOnQuerySiteInfoUserGroupsDone write FOnQuerySiteInfoUserGroupsDone;
// Meta information queries, site information, extensions: A list of extensions installed on the wiki (MW 1.14+)
private
FOnQuerySiteInfoExtensionsDone: TMediaWikiExtensionsCallback;
FQuerySiteInfoExtensions: TMediaWikiExtensions;
procedure QuerySiteInfoExtensionsParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QuerySiteInfoExtensions(out Infos: TMediaWikiExtensions); overload;
function QuerySiteInfoExtensions(OutputFormat: TMediaWikiOutputFormat): AnsiString; overload;
procedure QuerySiteInfoExtensionsAsync;
property OnQuerySiteInfoExtensionsDone: TMediaWikiExtensionsCallback read FOnQuerySiteInfoExtensionsDone write FOnQuerySiteInfoExtensionsDone;
(* TODO: fileextensions: A list of file extensions allowed to be uploaded (MW 1.15+) *)
(* TODO: rightsinfo: Get information about the license governing the wiki's content (MW 1.15+) *)
(* TODO: languages: Get available languages as seen in preferences (MW 1.16+) *)
// Meta information queries, tokens
private
FOnQueryTokensDone: TMediaWikiTokenValuesCallback;
FQueryTokenValues: TMediaWikiTokenValues;
procedure QueryTokensParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QueryTokens(Tokens: TMediaWikiTokens; out TokenValues: TMediaWikiTokenValues); overload;
function QueryTokens(Tokens: TMediaWikiTokens; OutputFormat: TMediaWikiOutputFormat): AnsiString; overload;
procedure QueryTokensAsync(Tokens: TMediaWikiTokens);
property OnQueryTokenDone: TMediaWikiTokenValuesCallback read FOnQueryTokensDone write FOnQueryTokensDone;
property QueryTokenValues: TMediaWikiTokenValues read FQueryTokenValues write FQueryTokenValues;
// Meta information queries, user information, blockinfo: Whether the current user is blocked, by whom, and why
private
FOnQueryUserInfoBlockInfoDone: TMediaWikiStringsCallback;
FQueryUserInfoBlockInfoStrings: TStrings;
procedure QueryUserInfoBlockInfoParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QueryUserInfoBlockInfo(Infos: TStrings); overload;
function QueryUserInfoBlockInfo(OutputFormat: TMediaWikiOutputFormat): AnsiString; overload;
procedure QueryUserInfoBlockInfoAsync;
property OnQueryUserInfoBlockInfoDone: TMediaWikiStringsCallback read FOnQueryUserInfoBlockInfoDone write FOnQueryUserInfoBlockInfoDone;
// Meta information queries, user information, hasmsg: Whether the current user has new messages on their user talk page
private
FOnQueryUserInfoHasMsgDone: TMediaWikiBooleanCallback;
FQueryUserInfoHasMsg: Boolean;
procedure QueryUserInfoHasMsgParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
function QueryUserInfoHasMsg: Boolean; overload;
function QueryUserInfoHasMsg(OutputFormat: TMediaWikiOutputFormat): AnsiString; overload;
procedure QueryUserInfoHasMsgAsync;
property OnQueryUserInfoHasMsgDone: TMediaWikiBooleanCallback read FOnQueryUserInfoHasMsgDone write FOnQueryUserInfoHasMsgDone;
// Meta information queries, user information, groups: Which groups the current user belongs to
private
FOnQueryUserInfoGroupsDone: TMediaWikiStringsCallback;
FQueryUserInfoGroupsStrings: TStrings;
procedure QueryUserInfoGroupsParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QueryUserInfoGroups(Infos: TStrings); overload;
function QueryUserInfoGroups(OutputFormat: TMediaWikiOutputFormat): AnsiString; overload;
procedure QueryUserInfoGroupsAsync;
property OnQueryUserInfoGroupsDone: TMediaWikiStringsCallback read FOnQueryUserInfoGroupsDone write FOnQueryUserInfoGroupsDone;
// Meta information queries, user information, rights: Which rights the current user has
private
FOnQueryUserInfoRightsDone: TMediaWikiStringsCallback;
FQueryUserInfoRightsStrings: TStrings;
procedure QueryUserInfoRightsParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QueryUserInfoRights(Infos: TStrings); overload;
function QueryUserInfoRights(OutputFormat: TMediaWikiOutputFormat): AnsiString; overload;
procedure QueryUserInfoRightsAsync;
property OnQueryUserInfoRightsDone: TMediaWikiStringsCallback read FOnQueryUserInfoRightsDone write FOnQueryUserInfoRightsDone;
// Meta information queries, user information, changeablegroups: Which groups the current user can add/remove
private
FOnQueryUserInfoChangeableGroupsDone: TMediaWikiStringsCallback;
FQueryUserInfoChangeableGroupsStrings: TStrings;
procedure QueryUserInfoChangeableGroupsParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QueryUserInfoChangeableGroups(Infos: TStrings); overload;
function QueryUserInfoChangeableGroups(OutputFormat: TMediaWikiOutputFormat): AnsiString; overload;
procedure QueryUserInfoChangeableGroupsAsync;
property OnQueryUserInfoChangeableGroupsDone: TMediaWikiStringsCallback read FOnQueryUserInfoChangeableGroupsDone write FOnQueryUserInfoChangeableGroupsDone;
// Meta information queries, user information, options: Which preferences the current user has
private
FOnQueryUserInfoOptionsDone: TMediaWikiStringsCallback;
FQueryUserInfoOptionsStrings: TStrings;
procedure QueryUserInfoOptionsParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QueryUserInfoOptions(Infos: TStrings); overload;
function QueryUserInfoOptions(OutputFormat: TMediaWikiOutputFormat): AnsiString; overload;
procedure QueryUserInfoOptionsAsync;
property OnQueryUserInfoOptionsDone: TMediaWikiStringsCallback read FOnQueryUserInfoOptionsDone write FOnQueryUserInfoOptionsDone;
// Meta information queries, user information, editcount: The number of edits the current user has made
private
FOnQueryUserInfoEditCountDone: TMediaWikiIntegerCallback;
FQueryUserInfoEditCount: Integer;
procedure QueryUserInfoEditCountParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
function QueryUserInfoEditCount: Integer; overload;
function QueryUserInfoEditCount(OutputFormat: TMediaWikiOutputFormat): AnsiString; overload;
procedure QueryUserInfoEditCountAsync;
property OnQueryUserInfoEditCountDone: TMediaWikiIntegerCallback read FOnQueryUserInfoEditCountDone write FOnQueryUserInfoEditCountDone;
// Meta information queries, user information, ratelimits: Rate limits applying to the current user
private
FOnQueryUserInfoRateLimitsDone: TMediaWikiRateLimitsCallback;
FQueryUserInfoRateLimits: TMediaWikiRateLimits;
procedure QueryUserInfoRateLimitsParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QueryUserInfoRateLimits(out Infos: TMediaWikiRateLimits); overload;
function QueryUserInfoRateLimits(OutputFormat: TMediaWikiOutputFormat): AnsiString; overload;
procedure QueryUserInfoRateLimitsAsync;
property OnQueryUserInfoRateLimitsDone: TMediaWikiRateLimitsCallback read FOnQueryUserInfoRateLimitsDone write FOnQueryUserInfoRateLimitsDone;
(* TODO: email: Email address and authentication timestamp in ISO 8601 format [1.15+] *)
// Meta information queries, allmessages: Lists the contents of all (or a few) interface messages.
private
FOnQueryMessagesDone: TMediaWikiStringsCallback;
FQueryMessagesStrings: TStrings;
procedure QueryMessagesParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QueryMessages(const NameFilter, ContentFilter, Lang: string; Infos: TStrings); overload;
function QueryMessages(const NameFilter, ContentFilter, Lang: string; OutputFormat: TMediaWikiOutputFormat): AnsiString; overload;
procedure QueryMessagesAsync(const NameFilter, ContentFilter, Lang: string);
property OnQueryMessagesDone: TMediaWikiStringsCallback read FOnQueryMessagesDone write FOnQueryMessagesDone;
// Queries, info / in: Gets basic page information
private
FOnQueryPageInfoDone: TMediaWikiPageInfosCallback;
FQueryPageInfos: TMediaWikiPageInfos;
procedure QueryPageInfoParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QueryPageInfo(const Titles: string; PageID: Boolean;
Flags: TMediaWikiPageInfoFlags; out Infos: TMediaWikiPageInfos); overload;
function QueryPageInfo(const Titles: string; PageID: Boolean;
Flags: TMediaWikiPageInfoFlags; OutputFormat: TMediaWikiOutputFormat): AnsiString; overload;
procedure QueryPageInfoAsync(const Titles: string; PageID: Boolean; Flags: TMediaWikiPageInfoFlags);
property OnQueryPageInfoDone: TMediaWikiPageInfosCallback read FOnQueryPageInfoDone write FOnQueryPageInfoDone;
// Queries, revisions / rv: Returns revisions for a given page
private
FOnQueryPageRevisionInfoDone: TMediaWikiPageRevisionInfosCallback;
FQueryPageRevisionInfos: TMediaWikiPageRevisionInfos;
FQueryPageRevisionContinueInfo: TMediaWikiContinueInfo;
procedure QueryPageRevisionInfoParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QueryPageRevisionInfo(const Titles: string; PageID: Boolean;
Flags: TMediaWikiPageRevisionInfoFlags; out Infos: TMediaWikiPageRevisionInfos;
var ContinueInfo: TMediaWikiContinueInfo;
MaxRevisions: Integer = 0; Section: Integer = -1; StartRevisionID: TMediaWikiID = -1;
EndRevisionID: TMediaWikiID = -1; const StartDateTime: TDateTime = 0.0;
const EndDateTime: TDateTime = 0.0; const IncludeUser: string = '';
const ExcludeUser: string = ''); overload;
function QueryPageRevisionInfo(const Titles: string; PageID: Boolean;
Flags: TMediaWikiPageRevisionInfoFlags; OutputFormat: TMediaWikiOutputFormat;
const ContinueInfo: TMediaWikiContinueInfo;
MaxRevisions: Integer = 0; Section: Integer = -1; StartRevisionID: TMediaWikiID = -1;
EndRevisionID: TMediaWikiID = -1; const StartDateTime: TDateTime = 0.0;
const EndDateTime: TDateTime = 0.0; const IncludeUser: string = '';
const ExcludeUser: string = ''): AnsiString; overload;
procedure QueryPageRevisionInfoAsync(const Titles: string; PageID: Boolean;
Flags: TMediaWikiPageRevisionInfoFlags; const ContinueInfo: TMediaWikiContinueInfo;
MaxRevisions: Integer = 0;
Section: Integer = -1; StartRevisionID: TMediaWikiID = -1;
EndRevisionID: TMediaWikiID = -1; const StartDateTime: TDateTime = 0.0;
const EndDateTime: TDateTime = 0.0; const IncludeUser: string = '';
const ExcludeUser: string = '');
property OnQueryPageRevisionInfoDone: TMediaWikiPageRevisionInfosCallback read FOnQueryPageRevisionInfoDone write FOnQueryPageRevisionInfoDone;
// Queries, categories / cl: Gets a list of all categories
private
FOnQueryPageCategoryInfoDone: TMediaWikiPageCategoryCallback;
FQueryPageCategoryInfos: TMediaWikiPageCategoryInfos;
FQueryPageCategoryContinueInfo: TMediaWikiContinueInfo;
procedure QueryPageCategoryInfoParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QueryPageCategoryInfo(const Titles: string; PageID: Boolean;
Flags: TMediaWikiPageCategoryInfoFlags; out Infos: TMediaWikiPageCategoryInfos;
var ContinueInfo: TMediaWikiContinueInfo;
MaxCategories: Integer = 0; const CategoryTitles: string = ''); overload;
function QueryPageCategoryInfo(const Titles: string; PageID: Boolean;
Flags: TMediaWikiPageCategoryInfoFlags; OutputFormat: TMediaWikiOutputFormat;
const ContinueInfo: TMediaWikiContinueInfo;
MaxCategories: Integer = 0; const CategoryTitles: string = ''): AnsiString; overload;
procedure QueryPageCategoryInfoAsync(const Titles: string; PageID: Boolean;
Flags: TMediaWikiPageCategoryInfoFlags; const ContinueInfo: TMediaWikiContinueInfo;
MaxCategories: Integer = 0; const CategoryTitles: string = '');
property OnQueryPageCategoryInfoDone: TMediaWikiPageCategoryCallback read FOnQueryPageCategoryInfoDone write FOnQueryPageCategoryInfoDone;
// Queries, imageinfo / ii: Gets image information TODO
// Queries, langlinks / ll: Gets a list of all language links TODO
// Queries, links / pl: Gets a list of all links
private
FOnQueryPageLinkInfoDone: TMediaWikiPageLinkCallback;
FQueryPageLinkInfos: TMediaWikiPageLinkInfos;
FQueryPageLinkContinueInfo: TMediaWikiContinueInfo;
procedure QueryPageLinkInfoParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QueryPageLinkInfo(const Titles: string; PageID: Boolean; out Infos: TMediaWikiPageLinkInfos;
var ContinueInfo: TMediaWikiContinueInfo; MaxLinks: Integer = 0; Namespace: Integer = -1); overload;
function QueryPageLinkInfo(const Titles: string; PageID: Boolean; OutputFormat: TMediaWikiOutputFormat;
const ContinueInfo: TMediaWikiContinueInfo; MaxLinks: Integer = 0; Namespace: Integer = -1): AnsiString; overload;
procedure QueryPageLinkInfoAsync(const Titles: string; PageID: Boolean;
const ContinueInfo: TMediaWikiContinueInfo; MaxLinks: Integer = 0; Namespace: Integer = -1);
property OnQueryPageLinkInfoDone: TMediaWikiPageLinkCallback read FOnQueryPageLinkInfoDone write FOnQueryPageLinkInfoDone;
// Queries, templates / tl: Gets a list of all pages included in the provided pages
private
FOnQueryPageTemplateInfoDone: TMediaWikiPageTemplateCallback;
FQueryPageTemplateInfos: TMediaWikiPageTemplateInfos;
FQueryPageTemplateContinueInfo: TMediaWikiContinueInfo;
procedure QueryPageTemplateInfoParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QueryPageTemplateInfo(const Titles: string; PageID: Boolean; out Infos: TMediaWikiPageTemplateInfos;
var ContinueInfo: TMediaWikiContinueInfo; MaxTemplates: Integer = 0; Namespace: Integer = -1); overload;
function QueryPageTemplateInfo(const Titles: string; PageID: Boolean; OutputFormat: TMediaWikiOutputFormat;
const ContinueInfo: TMediaWikiContinueInfo; MaxTemplates: Integer = 0; Namespace: Integer = -1): AnsiString; overload;
procedure QueryPageTemplateInfoAsync(const Titles: string; PageID: Boolean;
const ContinueInfo: TMediaWikiContinueInfo; MaxTemplates: Integer = 0; Namespace: Integer = -1);
property OnQueryPageTemplateInfoDone: TMediaWikiPageTemplateCallback read FOnQueryPageTemplateInfoDone write FOnQueryPageTemplateInfoDone;
// Queries, images / im: Gets a list of all images used on the provided pages TODO
// Queries, extlinks / el: Gets a list of all external links on the provided pages
private
FOnQueryPageExtLinkInfoDone: TMediaWikiPageExtLinkCallback;
FQueryPageExtLinkInfos: TMediaWikiPageExtLinkInfos;
FQueryPageExtLinkContinueInfo: TMediaWikiContinueInfo;
procedure QueryPageExtLinkInfoParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QueryPageExtLinkInfo(const Titles: string; PageID: Boolean; out Infos: TMediaWikiPageExtLinkInfos;
var ContinueInfo: TMediaWikiContinueInfo; MaxLinks: Integer = 0); overload;
function QueryPageExtLinkInfo(const Titles: string; PageID: Boolean; OutputFormat: TMediaWikiOutputFormat;
const ContinueInfo: TMediaWikiContinueInfo; MaxLinks: Integer = 0): AnsiString; overload;
procedure QueryPageExtLinkInfoAsync(const Titles: string; PageID: Boolean;
const ContinueInfo: TMediaWikiContinueInfo; MaxLinks: Integer = 0);
property OnQueryPageExtLinkInfoDone: TMediaWikiPageExtLinkCallback read FOnQueryPageExtLinkInfoDone write FOnQueryPageExtLinkInfoDone;
// Queries, categoryinfo / ci: Gets information about categories TODO
// Queries, duplicatefiles / df: List duplicates of the given files. TODO
// Queries, list, all pages: Returns a list of pages in a given namespace, ordered by page title.
private
FOnQueryAllPageInfoDone: TMediaWikiAllPageCallback;
FQueryAllPageInfos: TMediaWikiAllPageInfos;
FQueryAllPageContinueInfo: TMediaWikiContinueInfo;
procedure QueryAllPageInfoParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QueryAllPageInfo(out Infos: TMediaWikiAllPageInfos; var ContinueInfo: TMediaWikiContinueInfo;
const Prefix: string = ''; MaxPage: Integer = 0; Namespace: Integer = -1;
RedirFilter: TMediaWikiAllPageFilterRedir = mwfAllPageFilterAll;
LangFilter: TMediaWikiAllPageFilterLang = mwfAllPageLangAll; MinSize: Integer = -1; MaxSize: Integer = -1;
ProtectionFilter: TMediaWikiAllPageFilterProtection = mwfAllPageProtectionNone;
LevelFilter: TMediaWikiAllPageFilterLevel = mwfAllPageLevelNone;
Direction: TMediaWikiAllPageDirection = mwfAllPageAscending); overload;
function QueryAllPageInfo(OutputFormat: TMediaWikiOutputFormat; const ContinueInfo: TMediaWikiContinueInfo;
const Prefix: string = ''; MaxPage: Integer = 0; Namespace: Integer = -1;
RedirFilter: TMediaWikiAllPageFilterRedir = mwfAllPageFilterAll;
LangFilter: TMediaWikiAllPageFilterLang = mwfAllPageLangAll; MinSize: Integer = -1; MaxSize: Integer = -1;
ProtectionFilter: TMediaWikiAllPageFilterProtection = mwfAllPageProtectionNone;
LevelFilter: TMediaWikiAllPageFilterLevel = mwfAllPageLevelNone;
Direction: TMediaWikiAllPageDirection = mwfAllPageAscending): AnsiString; overload;
procedure QueryAllPageInfoAsync(const ContinueInfo: TMediaWikiContinueInfo; const Prefix: string = ''; MaxPage: Integer = 0;
Namespace: Integer = -1; RedirFilter: TMediaWikiAllPageFilterRedir = mwfAllPageFilterAll;
LangFilter: TMediaWikiAllPageFilterLang = mwfAllPageLangAll; MinSize: Integer = -1; MaxSize: Integer = -1;
ProtectionFilter: TMediaWikiAllPageFilterProtection = mwfAllPageProtectionNone;
LevelFilter: TMediaWikiAllPageFilterLevel = mwfAllPageLevelNone;
Direction: TMediaWikiAllPageDirection = mwfAllPageAscending);
property OnQueryAllPageInfoDone: TMediaWikiAllPageCallback read FOnQueryAllPageInfoDone write FOnQueryAllPageInfoDone;
// Queries, list, all links: Returns a list of (unique) links to pages in a given namespace starting ordered by link title.
private
FOnQueryAllLinkInfoDone: TMediaWikiAllLinkCallback;
FQueryAllLinkInfos: TMediaWikiAllLinkInfos;
FQueryAllLinkContinueInfo: TMediaWikiContinueInfo;
procedure QueryAllLinkInfoParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QueryAllLinkInfo(out Infos: TMediaWikiAllLinkInfos; var ContinueInfo: TMediaWikiContinueInfo;
const Prefix: string = ''; MaxLink: Integer = 0; Namespace: Integer = -1;
Flags: TMediaWikiAllLinkInfoFlags = []); overload;
function QueryAllLinkInfo(OutputFormat: TMediaWikiOutputFormat; const ContinueInfo: TMediaWikiContinueInfo;
const Prefix: string = ''; MaxLink: Integer = 0; Namespace: Integer = -1;
Flags: TMediaWikiAllLinkInfoFlags = []): AnsiString; overload;
procedure QueryAllLinkInfoAsync(const ContinueInfo: TMediaWikiContinueInfo;
const Prefix: string = ''; MaxLink: Integer = 0; Namespace: Integer = -1;
Flags: TMediaWikiAllLinkInfoFlags = []);
property OnQueryAllLinkInfoDone: TMediaWikiAllLinkCallback read FOnQueryAllLinkInfoDone write FOnQueryAllLinkInfoDone;
// Queries, list, all categories: Get a list of all categories.
private
FOnQueryAllCategoryInfoDone: TMediaWikiAllCategoriesCallback;
FQueryAllCategoryInfos: TStrings;
FQueryAllCategoryContinueInfo: TMediaWikiContinueInfo;
procedure QueryAllCategoryInfoParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QueryAllCategoryInfo(Infos: TStrings; var ContinueInfo: TMediaWikiContinueInfo;
const Prefix: string = ''; MaxCategory: Integer = 0; Flags: TMediaWikiAllCategoryInfoFlags = []); overload;
function QueryAllCategoryInfo(OutputFormat: TMediaWikiOutputFormat; const ContinueInfo: TMediaWikiContinueInfo;
const Prefix: string = ''; MaxCategory: Integer = 0; Flags: TMediaWikiAllCategoryInfoFlags = []): AnsiString; overload;
procedure QueryAllCategoryInfoAsync(const ContinueInfo: TMediaWikiContinueInfo;
const Prefix: string = ''; MaxCategory: Integer = 0; Flags: TMediaWikiAllCategoryInfoFlags = []);
property OnQueryAllCategoryInfoDone: TMediaWikiAllCategoriesCallback read FOnQueryAllCategoryInfoDone write FOnQueryAllCategoryInfoDone;
// Queries, list, all users: Get a list of registered users, ordered by username.
private
FOnQueryAllUserInfoDone: TMediaWikiAllUserCallback;
FQueryAllUserInfos: TMediaWikiAllUserInfos;
FQueryAllUserContinueInfo: TMediaWikiContinueInfo;
procedure QueryAllUserInfoParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QueryAllUserInfo(out Infos: TMediaWikiAllUserInfos; var ContinueInfo: TMediaWikiContinueInfo;
const Prefix: string = ''; const Group: string = ''; MaxUser: Integer = 0;
Flags: TMediaWikiAllUserInfoFlags = []); overload;
function QueryAllUserInfo(OutputFormat: TMediaWikiOutputFormat; const ContinueInfo: TMediaWikiContinueInfo;
const Prefix: string = ''; const Group: string = ''; MaxUser: Integer = 0;
Flags: TMediaWikiAllUserInfoFlags = []): AnsiString; overload;
procedure QueryAllUserInfoAsync(const ContinueInfo: TMediaWikiContinueInfo;
const Prefix: string = ''; const Group: string = ''; MaxUser: Integer = 0;
Flags: TMediaWikiAllUserInfoFlags = []);
property OnQueryAllUserInfoDone: TMediaWikiAllUserCallback read FOnQueryAllUserInfoDone write FOnQueryAllUserInfoDone;
// Queries, list, allimages / ai: Returns a list of all images, ordered by image title. TODO
// Queries, list, all backlinks / bl: Lists pages that link to a given page, similar to Special:Whatlinkshere. Ordered by linking page title.
private
FOnQueryBackLinkInfoDone: TMediaWikiBackLinkCallback;
FQueryBackLinkInfos: TMediaWikiBackLinkInfos;
FQueryBackLinkContinueInfo: TMediaWikiContinueInfo;
procedure QueryBackLinkInfoParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QueryBackLinkInfo(const BackLinkTitle: string; out Infos: TMediaWikiBackLinkInfos;
var ContinueInfo: TMediaWikiContinueInfo; Namespace: Integer = -1; MaxLink: Integer = 0;
Flags: TMediaWikiBackLinkInfoFlags = []); overload;
function QueryBackLinkInfo(const BackLinkTitle: string; OutputFormat: TMediaWikiOutputFormat;
const ContinueInfo: TMediaWikiContinueInfo; Namespace: Integer = -1; MaxLink: Integer = 0;
Flags: TMediaWikiBackLinkInfoFlags = []): AnsiString; overload;
procedure QueryBackLinkInfoAsync(const BackLinkTitle: string;
const ContinueInfo: TMediaWikiContinueInfo; Namespace: Integer = -1; MaxLink: Integer = 0;
Flags: TMediaWikiBackLinkInfoFlags = []);
property OnQueryBackLinkInfoDone: TMediaWikiBackLinkCallback read FOnQueryBackLinkInfoDone write FOnQueryBackLinkInfoDone;
// Queries, list, all blocks / bk: List all blocks, à la Special:Ipblocklist. This module cannot be used as a generator.
private
FOnQueryBlockInfoDone: TMediaWikiBlockCallback;
FQueryBlockInfos: TMediaWikiBlockInfos;
FQueryBlockContinueInfo: TMediaWikiContinueInfo;
procedure QueryBlockInfoParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QueryBlockInfo(out Infos: TMediaWikiBlockInfos; var ContinueInfo: TMediaWikiContinueInfo;
const StartDateTime: TDateTime = 0.0; const StopDateTime: TDateTime = 0.0;
const BlockIDs: string = ''; const Users: string = ''; const IP: string = ''; MaxBlock: Integer = 0;
Flags: TMediaWikiBlockInfoFlags = []); overload;
function QueryBlockInfo(OutputFormat: TMediaWikiOutputFormat; const ContinueInfo: TMediaWikiContinueInfo;
const StartDateTime: TDateTime = 0.0; const StopDateTime: TDateTime = 0.0;
const BlockIDs: string = ''; const Users: string = ''; const IP: string = ''; MaxBlock: Integer = 0;
Flags: TMediaWikiBlockInfoFlags = []): AnsiString; overload;
procedure QueryBlockInfoAsync(const ContinueInfo: TMediaWikiContinueInfo;
const StartDateTime: TDateTime = 0.0; const StopDateTime: TDateTime = 0.0;
const BlockIDs: string = ''; const Users: string = ''; const IP: string = ''; MaxBlock: Integer = 0;
Flags: TMediaWikiBlockInfoFlags = []);
property OnQueryBlockInfoDone: TMediaWikiBlockCallback read FOnQueryBlockInfoDone write FOnQueryBlockInfoDone;
// Queries, list, categorymembers / cm: List of pages that belong to a given category, ordered by page sort title.
private
FOnQueryCategoryMemberInfoDone: TMediaWikiCategoryMemberCallback;
FQueryCategoryMemberInfos: TMediaWikiCategoryMemberInfos;
FQueryCategoryMemberContinueInfo: TMediaWikiContinueInfo;
procedure QueryCategoryMemberInfoParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure QueryCategoryMemberInfo(const CategoryTitle: string; out Infos: TMediaWikiCategoryMemberInfos;
var ContinueInfo: TMediaWikiContinueInfo; PageNamespace: Integer = -1;
const StartDateTime: TDateTime = 0.0; const StopDateTime: TDateTime = 0.0;
const StartSortKey: string = ''; const StopSortKey: string = ''; MaxCategoryMember: Integer = 0;
Flags: TMediaWikiCategoryMemberInfoFlags = []); overload;
function QueryCategoryMemberInfo(const CategoryTitle: string; OutputFormat: TMediaWikiOutputFormat;
const ContinueInfo: TMediaWikiContinueInfo; PageNamespace: Integer = -1;
const StartDateTime: TDateTime = 0.0; const StopDateTime: TDateTime = 0.0;
const StartSortKey: string = ''; const StopSortKey: string = ''; MaxCategoryMember: Integer = 0;
Flags: TMediaWikiCategoryMemberInfoFlags = []): AnsiString; overload;
procedure QueryCategoryMemberInfoAsync(const CategoryTitle: string;
const ContinueInfo: TMediaWikiContinueInfo; PageNamespace: Integer = -1;
const StartDateTime: TDateTime = 0.0; const StopDateTime: TDateTime = 0.0;
const StartSortKey: string = ''; const StopSortKey: string = ''; MaxCategoryMember: Integer = 0;
Flags: TMediaWikiCategoryMemberInfoFlags = []);
property OnQueryCategoryMemberInfoDone: TMediaWikiCategoryMemberCallback read FOnQueryCategoryMemberInfoDone write FOnQueryCategoryMemberInfoDone;
// Queries, list, embeddedin / ei: List pages that include a certain page TODO
// Queries, list, exturlusage / eu: Get a list of pages that link to a certain URL, à la Special:Linksearch TODO
// Queries, list, imageusage / iu: List of pages that include a given image. Ordered by page title. TODO
// Queries, list, logevents / le: Get a list of all logged events, à la Special:Log. This module cannot be used as a generator. TODO
// Queries, list, recentchanges / rc: Get all recent changes to the wiki, à la Special:Recentchanges. This module cannot be used as a generator. TODO
// Queries, list, search / sr: Search for a string in all articles à la Special:Search TODO
// Queries, list, usercontribs / uc: Gets a list of contributions made by a given user, ordered by modification time. This module cannot be used as a generator. TODO
// Queries, list, watchlist / wl: Get a list of pages on the current user's watchlist that were changed within the given time period. Ordered by time of the last change of the watched page. TODO
// Queries, list, deletedrevs / dr: List deleted revisions. TODO
// Queries, list, users / us: Get information about a list of users. TODO
// Queries, list, random / rn: Get a list of random pages. TODO
// Queries, list, protectedtitles / pt: Get a list of titles protected from creation. TODO
// Edit
private
FOnEditDone: TMediaWikiEditCallback;
FEditInfo: TMediaWikiEditInfo;
procedure EditParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure Edit(const PageTitle, Section, Text, PrependText, AppendText, EditToken, Summary: string;
out EditInfo: TMediaWikiEditInfo;
const MD5: string = ''; const CaptchaID: string = ''; const CaptchaWord: string = '';
const BaseDateTime: TDateTime = 0.0; const StartDateTime: TDateTime = 0.0;
UndoRevisionID: TMediaWikiID = -1; Flags: TMediaWikiEditFlags = []); overload;
function Edit(const PageTitle, Section, Text, PrependText, AppendText, EditToken, Summary: string;
OutputFormat: TMediaWikiOutputFormat;
const MD5: string = ''; const CaptchaID: string = ''; const CaptchaWord: string = '';
const BaseDateTime: TDateTime = 0.0; const StartDateTime: TDateTime = 0.0;
UndoRevisionID: TMediaWikiID = -1; Flags: TMediaWikiEditFlags = []): AnsiString; overload;
procedure EditAsync(const PageTitle, Section, Text, PrependText, AppendText, EditToken, Summary: string;
const MD5: string = ''; const CaptchaID: string = ''; const CaptchaWord: string = '';
const BaseDateTime: TDateTime = 0.0; const StartDateTime: TDateTime = 0.0;
UndoRevisionID: TMediaWikiID = -1; Flags: TMediaWikiEditFlags = []);
property OnEditDone: TMediaWikiEditCallback read FOnEditDone write FOnEditDone;
// Move
private
FOnMoveDone: TMediaWikiMoveCallback;
FMoveInfo: TMediaWikiMoveInfo;
procedure MoveParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure Move(const FromPageTitle, ToPageTitle, MoveToken, Reason: string;
FromPageID: TMediaWikiID; Flags: TMediaWikiMoveFlags; out MoveInfo: TMediaWikiMoveInfo); overload;
function Move(const FromPageTitle, ToPageTitle, MoveToken, Reason: string;
FromPageID: TMediaWikiID; Flags: TMediaWikiMoveFlags; OutputFormat: TMediaWikiOutputFormat): AnsiString; overload;
procedure MoveAsync(const FromPageTitle, ToPageTitle, MoveToken, Reason: string;
FromPageID: TMediaWikiID; Flags: TMediaWikiMoveFlags);
property OnMoveDone: TMediaWikiMoveCallback read FOnMoveDone write FOnMoveDone;
// Rollback TODO
// Delete
private
FOnDeleteDone: TMediaWikiDeleteCallback;
FDeleteInfo: TMediaWikiDeleteInfo;
procedure DeleteParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure Delete(const PageTitle, DeleteToken, Reason: string;
FromPageID: TMediaWikiID; out DeleteInfo: TMediaWikiDeleteInfo;
Suppress: Boolean = False); overload;
function Delete(const PageTitle, DeleteToken, Reason: string;
FromPageID: TMediaWikiID; OutputFormat: TMediaWikiOutputFormat;
Suppress: Boolean = False): AnsiString; overload;
procedure DeleteAsync(const PageTitle, DeleteToken, Reason: string;
FromPageID: TMediaWikiID; Suppress: Boolean = False);
property OnDeleteDone: TMediaWikiDeleteCallback read FOnDeleteDone write FOnDeleteDone;
// Delete Revision
private
FOnDeleteRevisionDone: TMediaWikiDeleteRevisionCallback;
FDeleteRevisionInfo: TMediaWikiDeleteRevisionInfo;
procedure DeleteRevisionParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure DeleteRevision(const PageTitle, DeleteToken, Reason: string;
FromPageID, RevisionID: TMediaWikiID; out DeleteRevisionInfo: TMediaWikiDeleteRevisionInfo); overload;
function DeleteRevision(const PageTitle, DeleteToken, Reason: string;
FromPageID, RevisionID: TMediaWikiID; OutputFormat: TMediaWikiOutputFormat): AnsiString; overload;
procedure DeleteRevisionAsync(const PageTitle, DeleteToken, Reason: string;
FromPageID, RevisionID: TMediaWikiID);
property OnDeleteRevisionDone: TMediaWikiDeleteRevisionCallback read FOnDeleteRevisionDone write FOnDeleteRevisionDone;
// restore deleted revisions TODO
// (un)protect pages TODO
// (Un)block users TODO
// (Un)watch pages TODO
// Send e-mail TODO
// Patrol changes TODO
// Import pages TODO
// Change user group membership TODO
// Upload files TODO
private
FOnUploadDone: TMediaWikiUploadCallback;
FUploadInfo: TMediaWikiUploadInfo;
procedure UploadParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure Upload(const FileName, Comment, Text, EditToken: string;
Flags: TMediaWikiUploadFlags; Content: TStream; const URL: string;
out UploadInfo: TMediaWikiUploadInfo); overload;
function Upload(const FileName, Comment, Text, EditToken: string;
Flags: TMediaWikiUploadFlags; Content: TStream; const URL: string;
OutputFormat: TMediaWikiOutputFormat): AnsiString; overload;
procedure UploadAsync(const FileName, Comment, Text, EditToken: string;
Flags: TMediaWikiUploadFlags; Content: TStream; const URL: string);
property OnUploadDone: TMediaWikiUploadCallback read FOnUploadDone write FOnUploadDone;
// User Merge
private
FOnUserMergeDone: TMediaWikiUserMergeCallback;
FUserMergeInfo: TMediaWikiUserMergeInfo;
procedure UserMergeParseXmlResult(Sender: TMediaWikiApi; XML: TJclSimpleXML);
public
procedure UserMerge(const OldUser, NewUser, Token: string;
DeleteUser: Boolean; out UserMergeInfo: TMediaWikiUserMergeInfo); overload;
function UserMerge(const OldUser, NewUser, Token: string;
DeleteUser: Boolean; OutputFormat: TMediaWikiOutputFormat): AnsiString; overload;
procedure UserMergeAsync(const OldUser, NewUser, Token: string;
DeleteUser: Boolean);
property OnUserMergeDone: TMediaWikiUserMergeCallback read FOnUserMergeDone write FOnUserMergeDone;
end;
{$TYPEINFO OFF}
implementation
uses
JclStrings,
JclStreams;
//=== { TMediaWikiApi } ======================================================
constructor TMediaWikiApi.Create;
begin
inherited Create;
FIgnoreWarnings := True;
FIgnoreErrors := False;
FHttpsCli := TSslHttpCli.Create(nil);
FHttpsCli.OnRequestDone := RequestDone;
FHttpsCli.OnCookie := OnCookieRcvd;
FSslContext := TSslContext.Create(nil);
FHttpsCli.SslContext := FSslContext;
FSendStream := TMemoryStream.Create;
FReceiveStream := TMemoryStream.Create;
FHttpsCli.SendStream := FSendStream;
FHttpsCli.RcvdStream := FReceiveStream;
FQueryStrings := TStringList.Create;
end;
destructor TMediaWikiApi.Destroy;
begin
if LoginUserID <> 0 then
Logout;
FQueryStrings.Free;
FSendStream.Free;
FReceiveStream.Free;
FHttpsCli.Free;
inherited Destroy;
end;
procedure TMediaWikiApi.OnCookieRcvd(Sender: TObject; const Data: String;
var Accept: Boolean);
var
Cookies: TStrings;
Cookie, Name, Value: string;
begin
Cookies := TStringList.Create;
try
StrToStrings(FHttpsCli.Cookie, '; ', Cookies);
Cookie := StrBefore(';',Data);
Name := StrBefore('=', Cookie);
Value := StrAfter('=', Cookie);
Cookies.Values[Name] := Value;
FHttpsCli.Cookie := StringsToStr(Cookies,'; ', False);
finally
Cookies.Free;
end;
Accept := True;
end;
procedure TMediaWikiApi.CheckRequest(Request: TMediaWikiRequest);
begin
// check socket ready state, done by httpcli
if FPendingRequests * MediaWikiExclusiveRequests <> [] then
raise EMediaWikiError.Create('execute exclusive request first', '');
Include(FPendingRequests, Request);
end;
function TMediaWikiApi.GetReady: Boolean;
begin
Result := HttpsCli.State = httpReady;
end;
procedure TMediaWikiApi.ProcessXMLError(const AInfo, ACode: string);
var
Ignore: Boolean;
begin
Ignore := IgnoreErrors;
if Assigned(FOnError) then
FOnError(Self, AInfo, ACode, Ignore);
if not Ignore then
raise EMediaWikiError.Create(AInfo, ACode);
end;
procedure TMediaWikiApi.ProcessXMLWarning(const AInfo, AQuery: string);
var
Ignore: Boolean;
begin
Ignore := IgnoreWarnings;
if Assigned(FOnWarning) then
FOnWarning(Self, AInfo, AQuery, Ignore);
if not Ignore then
raise EMediaWikiWarning.Create(AInfo, AQuery);
end;
function TMediaWikiApi.QueryExecute: AnsiString;
var
ContentType: string;
begin
FSendStream.Size := 0;
MediaWikiQueryPost(FQueryStrings, FSendStream, ContentType);
FHttpsCli.ContentTypePost := ContentType;
FSendStream.Position := 0;
FReceiveStream.Size := 0;
FHttpsCli.Post;
FPendingRequests := [];
SetLength(Result, FReceiveStream.Size);
FReceiveStream.Position := 0;
FReceiveStream.ReadBuffer(Result[1], Length(Result));
end;
procedure TMediaWikiApi.QueryExecuteAsync;
var
ContentType: AnsiString;
begin
FSendStream.Size := 0;
MediaWikiQueryPost(FQueryStrings, FSendStream, ContentType);
FHttpsCli.ContentTypePost := ContentType;
FSendStream.Position := 0;
FReceiveStream.Size := 0;
FHttpsCli.PostASync;
end;
procedure TMediaWikiApi.QueryExecuteXML(XML: TJclSimpleXML);
var
ContentType: string;
begin
FSendStream.Size := 0;
MediaWikiQueryPost(FQueryStrings, FSendStream, ContentType);
FHttpsCli.ContentTypePost := ContentType;
FSendStream.Position := 0;
FReceiveStream.Size := 0;
FHttpsCli.Post;
FPendingRequests := [];
FReceiveStream.Position := 0;
try
XML.LoadFromStream(FReceiveStream, seUTF8);
except
FReceiveStream.Position := 0;
// FReceiveStream.SaveToFile('c:\dev\receive.xml');
raise;
end;
MediaWikiCheckXML(XML, ProcessXMLWarning, ProcessXMLError);
end;
function TMediaWikiApi.Login(const lgName, lgPassword, lgToken: string;
OutputFormat: TMediaWikiOutputFormat): AnsiString;
begin
QueryInit;
CheckRequest(mwrLogin);
MediaWikiQueryLoginAdd(FQueryStrings, lgName, lgPassword, lgToken, OutputFormat);
Result := QueryExecute;
end;
function TMediaWikiApi.Login: TMediaWikiLoginResult;
begin
Result := Login(LoginUserName, LoginPassword);
end;
function TMediaWikiApi.Login(const lgName, lgPassword: string): TMediaWikiLoginResult;
var
Tokens: TMediaWikiTokenValues;
begin
QueryTokens([mwtLogin],Tokens);
FLoginToken := Tokens[mwtLogin];
Result := Login(lgName, lgPassword, FLoginToken);
end;
function TMediaWikiApi.Login(const lgName, lgPassword,
lgToken: string): TMediaWikiLoginResult;
var
XML: TJclSimpleXML;
begin
XML := TJclSimpleXML.Create;
try
QueryInit;
CheckRequest(mwrLogin);
MediaWikiQueryLoginAdd(FQueryStrings, lgName, lgPassword, lgToken, mwoXML);
QueryExecuteXml(XML);
LoginParseXmlResult(Self, XML);
Result := LoginResult;
finally
XML.Free;
end;
end;
procedure TMediaWikiApi.LoginAsync;
begin
OnQueryTokenDone := LoginGetToken;
FRequestCallbacks[mwrLogin] := LoginParseXmlResult;
CheckRequest(mwrLogin);
QueryTokensAsync([mwtLogin]);
end;
procedure TMediaWikiApi.LoginAsync(const lgName, lgPassword: string);
begin
FLoginUserName := lgName;
FLoginPassword := lgPassword;