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
|
unit TsRemoteImport;
interface
(*
25-7-2003
added Function tsrGetSpeakers( IDs : PInteger; RecordCount: PInteger): Integer;
*)
{$ifdef mswindows}
Const LibName= 'TSRemote.dll';
{$endif}
{$ifdef LINUX}
Const LibName= 'libTSRemote.so.0.4';
{$endif}
const
cCodecCelp51 = 0;
cCodecCelp63 = 1;
cCodecGSM148 = 2;
cCodecGSM164 = 3;
cCodecWindowsCELP52 = 4;
//codec masks
cmCelp51 = 1 shl cCodecCelp51;
cmCelp63 = 1 shl cCodecCelp63;
cmGSM148 = 1 shl cCodecGSM148;
cmGSM164 = 1 shl cCodecGSM164;
cmWindowsCELP52 = 1 shl cCodecWindowsCELP52;
//PlayerChannelPrivileges
pcpAdmin = 1 shl 0;
pcpOperator = 1 shl 1;
pcpAutoOperator = 1 shl 2;
pcpVoiced = 1 shl 3;
pcpAutoVoice = 1 shl 4;
//PlayerPrivileges
ppSuperServerAdmin = 1 shl 0;
ppServerAdmin = 1 shl 1;
ppCanRegister = 1 shl 2;
ppRegistered = 1 shl 3;
ppUnregistered = 1 shl 4;
//player flags
pfChannelCommander = 1 shl 0;
pfWantVoice = 1 shl 1;
pfNoWhisper = 1 shl 2;
pfAway = 1 shl 3;
pfInputMuted = 1 shl 4;
pfOutputMuted = 1 shl 5;
pfRecording = 1 shl 6;
//channel flags
cfRegistered = 1 shl 0;
cfUnregistered = 1 shl 1;
cfModerated = 1 shl 2;
cfPassword = 1 shl 3;
cfHierarchical = 1 shl 4;
cfDefault = 1 shl 5;
//ServerType Flags
stClan = 1 shl 0;
stPublic = 1 shl 1;
stFreeware = 1 shl 2;
stCommercial = 1 shl 3;
grRevoke = 0;
grGrant = 1;
Type
PtsrPlayerInfo = ^TtsrPlayerInfo;
TtsrPlayerInfo = packed record
PlayerID : Integer;
ChannelID : Integer;
NickName : Array [0..29] of Char;
PlayerChannelPrivileges : Integer;
PlayerPrivileges : Integer;
PlayerFlags : Integer;
end;
PtsrChannelInfo = ^TtsrChannelInfo;
TtsrChannelInfo = packed record
ChannelID : Integer;
ChannelParentID : Integer;
PlayerCountInChannel : Integer;
ChannelFlags : Integer;
Codec : Integer;
Name : Array [0..29] of Char;
end;
PtsrVersion = ^TtsrVersion;
TtsrVersion = packed record
Major : Integer;
Minor : Integer;
Release : Integer;
Build : Integer;
end;
PtsrServerInfo = ^TtsrServerInfo;
TtsrServerInfo = packed record
ServerName : Array [0..29] of Char;
WelcomeMessage : Array [0..255] of Char;
ServerVMajor : Integer;
ServerVMinor : Integer;
ServerVRelease : Integer;
ServerVBuild : Integer;
ServerPlatform : Array [0..29] of Char;
ServerIp : Array [0..29] of Char;
ServerHost : Array [0..99] of Char;
ServerType : Integer;
ServerMaxUsers : Integer;
SupportedCodecs : Integer;
ChannelCount : Integer;
PlayerCount : Integer;
end;
PtsrUserInfo = ^TtsrUserInfo;
TtsrUserInfo = packed record
Player : TtsrPlayerInfo;
Channel : TtsrChannelInfo;
ParentChannel : TtsrChannelInfo;
end;
//##############################################################################
//#
//# Function InitTsRemoteLibrary(TryLocal: Boolean): Integer;
//#
//# Description:
//# Loads and binds the TSRemote library
//#
//# Input:
//# TryLocal: if true, it will try to load the library from the same dir
//# as the program location. If that fails it will fall back to
//# the default locations.
//#
//# Output:
//# Result: (0=ok, -1= library already initialized,
//# -2=error loading library
//# -3=error during binding functions
//#
//##############################################################################
Function InitTsRemoteLibrary(TryLocal: Boolean): Integer;
//##############################################################################
//#
//# Function CloseTsRemoteLibrary: integer
//#
//# Description:
//# Frees the hawkvoice library loaded by InitTsRemoteLibrary
//#
//# Input:
//# None
//#
//# Output:
//# Result: (0=ok, -1= library not initialized, -2=error during FreeLibrary
//#
//##############################################################################
Function CloseTsRemoteLibrary: Integer;
//##############################################################################
//#
//# Procedure tsrGetLastError(pchBuffer : PChar; BufferLength: Integer)
//#
//# Description:
//# Get the full error message that was send with the last error
//#
//# Input:
//# pchBuffer: A pointer to a nulterminated string where the error message
//# will be copied to.
//# BufferLength: The size of pchBuffer
//#
//# Output:
//# None
//#
//##############################################################################
type TtsrGetLastError = Procedure (pchBuffer : PChar; BufferLength: Integer);{$ifdef linux}cdecl;{$endif}{$ifdef mswindows}stdcall;{$endif}
var tsrGetLastError : TtsrGetLastError;
const fn_tsrGetLastError='tsrGetLastError';
//##############################################################################
//#
//# Function tsrConnect(URL :Pchar): integer
//#
//# Description:
//# Connect the ts to a new server as described in the URL. Will disconnect
//# if the client is currently connected. The Url is the same format as the
//# normal starup link ("teamspeak://voice.teamspeak.org:9500" etc)
//#
//# Input:
//# URL: A pointer to a null terminated string containing the url for the
//# server.
//#
//# Output:
//# Result: 0 = OK, else the error number
//#
//##############################################################################
type TtsrConnect = Function (URL :Pchar): Integer;{$ifdef linux}cdecl;{$endif}{$ifdef mswindows}stdcall;{$endif}
var tsrConnect : TtsrConnect;
const fn_tsrConnect='tsrConnect';
//##############################################################################
//#
//# Function tsrDisconnect: integer
//#
//# Description:
//# Disconnects the client from the current server.
//#
//# Input:
//# None
//#
//# Output:
//# Result: 0 = OK, else the error number
//#
//##############################################################################
type TtsrDisconnect = Function: Integer;{$ifdef linux}cdecl;{$endif}{$ifdef mswindows}stdcall;{$endif}
var tsrDisconnect : TtsrDisconnect;
const fn_tsrDisconnect='tsrDisconnect';
//##############################################################################
//#
//# Function tsrQuit: integer
//#
//# Description:
//# Disconnect, Close and terminate the client.
//#
//# Input:
//# None
//#
//# Output:
//# Result: 0 = OK, else the error number
//#
//##############################################################################
type TtsrQuit = Function: Integer;{$ifdef linux}cdecl;{$endif}{$ifdef mswindows}stdcall;{$endif}
var tsrQuit : TtsrQuit;
const fn_tsrQuit='tsrQuit';
//##############################################################################
//#
//# Function tsrSwitchChannelName( ChannelName: PChar;
//# ChannelPassword: PChar): Integer;
//#
//# Description:
//# Switch to the channel with the name "Channelname"
//# Not that tsrSwitchChannelID is preferred.
//#
//# Input:
//# ChannelName: Name of the channel to switch to
//# ChannelPassword: Password for the channel. May be nil
//#
//# Output:
//# Result: 0 = OK, else the error number
//#
//##############################################################################
type TtsrSwitchChannelName = Function( ChannelName: Pchar;
ChannelPassword: PChar): Integer;
{$ifdef linux}cdecl;{$endif}{$ifdef mswindows}stdcall;{$endif}
var tsrSwitchChannelName : TtsrSwitchChannelName;
const fn_tsrSwitchChannelName='tsrSwitchChannelName';
//##############################################################################
//#
//# Function tsrSwitchChannelID( ChannelID : Integer;
//# ChannelPassword: PChar): Integer;
//#
//# Description:
//# Switch to the channel with the id "channelID"
//#
//# Input:
//# ChannelID : ID of the channel to switch to
//# ChannelPassword: Password for the channel. May be nil
//#
//# Output:
//# Result: 0 = OK, else the error number
//#
//##############################################################################
type TtsrSwitchChannelID = Function( ChannelID: Integer;
ChannelPassword: PChar): Integer;
{$ifdef linux}cdecl;{$endif}{$ifdef mswindows}stdcall;{$endif}
var tsrSwitchChannelID : TtsrSwitchChannelID;
const fn_tsrSwitchChannelID='tsrSwitchChannelID';
//##############################################################################
//#
//# Function tsrGetVersion( tsrVersion: PtsrVersion ): Integer;
//#
//# Description:
//# Get the version of the ts client
//#
//# Input:
//# Pointer to a TtsrVersion record
//#
//# Output:
//# Result: 0 = OK, else the error number
//# if result = 0 then tsrVersion is filled with the client version
//#
//##############################################################################
type TtsrGetVersion = Function( tsrVersion: PtsrVersion ): Integer;
{$ifdef linux}cdecl;{$endif}{$ifdef mswindows}stdcall;{$endif}
var tsrGetVersion : TtsrGetVersion;
const fn_tsrGetVersion='tsrGetVersion';
//##############################################################################
//#
//# Function TtsrGetServerInfo( tsrServerInfo: PtsrServerInfo ): Integer;
//#
//# Description:
//# Get the Info on the server (name, channelcount, playercount etc etc)
//#
//# Input:
//# Pointer to a TtsrServerInfo record
//#
//# Output:
//# Result: 0 = OK, else the error number
//# if result = 0 then tsrServerInfo is filled with the server info
//#
//##############################################################################
type TtsrGetServerInfo = Function ( tsrServerInfo: PtsrServerInfo ): Integer;
{$ifdef linux}cdecl;{$endif} {$ifdef mswindows}stdcall;{$endif}
var tsrGetServerInfo : TtsrGetServerInfo;
Const fn_tsrGetServerInfo='tsrGetServerInfo';
//##############################################################################
//#
//# Function tsrGetUserInfo( tsrUserInfo: PtsrUserInfo ): Integer;
//#
//# Description:
//# Get the Info on the user (name, channel, flags etc etc)
//#
//# Input:
//# Pointer to a TtsrUserInfo record
//#
//# Output:
//# Result: 0 = OK, else the error number
//# if result = 0 then tsrUserInfo is filled with the user info
//#
//##############################################################################
type TtsrGetUserInfo = Function ( tsrUserInfo: PtsrUserInfo ): Integer;
{$ifdef linux}cdecl;{$endif} {$ifdef mswindows}stdcall;{$endif}
var tsrGetUserInfo : TtsrGetUserInfo;
Const fn_tsrGetUserInfo='tsrGetUserInfo';
//##############################################################################
//#
//# Function tsrGetChannelInfoByID( ChannelID: Integer;
//# tsrChannelInfo: PtsrChannelInfo;
//# tsrPlayerInfo : PtsrPlayerInfo; PlayerRecords : PInteger) : integer;
//#
//# Description:
//# Get the Info on the channel specified by ChannelID and optionally also
//# get the users from that channel
//#
//# Input:
//# ChannelID: The ID of the channel you want the info from
//# tsrChannelInfo: pointer to a TtsrChannelInfo record;
//# tsrPlayerInfo: This is the pointer to an array of TtsrPlayerInfo records
//# If it is NIL, no player records will be retrieved
//# PlayerRecords: Pointer to an integer. It must contain how many records
//# tsrPlayerInfo has room for. (records, not bytes)
//#
//# Output:
//# Result: 0 = OK, else the error number
//# if result = 0 then tsrChannelInfo is filled with the channel info.
//# If tsrPlayerInfo was not NIL then the player records are
//# filled. PlayerRecords indicates how many records were filled
//#
//##############################################################################
type TtsrGetChannelInfoByID = Function ( ChannelID: Integer; tsrChannelInfo: PtsrChannelInfo;
tsrPlayerInfo : PtsrPlayerInfo; PlayerRecords : PInteger) : integer;
{$ifdef linux}cdecl;{$endif} {$ifdef mswindows}stdcall;{$endif}
var tsrGetChannelInfoByID : TtsrGetChannelInfoByID;
Const fn_tsrGetChannelInfoByID='tsrGetChannelInfoByID';
//##############################################################################
//#
//# Function tsrGetChannelInfoByName( ChannelName: PChar;
//# tsrChannelInfo: PtsrChannelInfo;
//# tsrPlayerInfo : PtsrPlayerInfo; PlayerRecords : PInteger) : integer;
//#
//# Description:
//# Get the Info on the channel specified by ChannelName and optionally also
//# get the users from that channel
//#
//# Input:
//# ChannelName: The Name of the channel you want the info from
//# tsrChannelInfo: pointer to a TtsrChannelInfo record;
//# tsrPlayerInfo: This is the pointer to an array of TtsrPlayerInfo records
//# If it is NIL, no player records will be retrieved
//# PlayerRecords: Pointer to an integer. It must contain how many records
//# tsrPlayerInfo has room for. (records, not bytes)
//#
//# Output:
//# Result: 0 = OK, else the error number
//# if result = 0 then tsrChannelInfo is filled with the channel info.
//# If tsrPlayerInfo was not NIL then the player records are
//# filled. PlayerRecords indicates how many records were filled
//#
//##############################################################################
type TtsrGetChannelInfoByName = Function ( ChannelName: PChar; tsrChannelInfo: PtsrChannelInfo;
tsrPlayerInfo : PtsrPlayerInfo; PlayerRecords : PInteger) : integer;
{$ifdef linux}cdecl;{$endif} {$ifdef mswindows}stdcall;{$endif}
var tsrGetChannelInfoByName : TtsrGetChannelInfoByName;
Const fn_tsrGetChannelInfoByName='tsrGetChannelInfoByName';
//##############################################################################
//#
//# Function tsrGetPlayerInfoByID( PlayerID: Integer;
//# tsrPlayerInfo : PtsrPlayerInfo): Integer;
//#
//# Description:
//# Get the Info on the player specified by PlayerID.
//#
//# Input:
//# PlayerID: The ID of the player you want the info from
//# tsrPlayerInfo: This is the pointer to a TtsrPlayerInfo record
//#
//# Output:
//# Result: 0 = OK, else the error number
//# if result = 0 then tsrPlayerInfo is filled with the player info.
//#
//##############################################################################
type TtsrGetPlayerInfoByID = Function ( PlayerID: Integer; tsrPlayerInfo : PtsrPlayerInfo): Integer;
{$ifdef linux}cdecl;{$endif} {$ifdef mswindows}stdcall;{$endif}
var tsrGetPlayerInfoByID : TtsrGetPlayerInfoByID;
Const fn_tsrGetPlayerInfoByID='tsrGetPlayerInfoByID';
//##############################################################################
//#
//# Function tsrGetPlayerInfoByName( PlayerName : Pchar
//# tsrPlayerInfo : PtsrPlayerInfo): Integer;
//#
//# Description:
//# Get the Info on the player specified by PlayerName.
//#
//# Input:
//# PlayerName: The Name of the player you want the info from
//# tsrPlayerInfo: This is the pointer to a TtsrPlayerInfo record
//#
//# Output:
//# Result: 0 = OK, else the error number
//# if result = 0 then tsrPlayerInfo is filled with the player info.
//#
//##############################################################################
type TtsrGetPlayerInfoByName = Function ( PlayerName: Pchar; tsrPlayerInfo : PtsrPlayerInfo): Integer;
{$ifdef linux}cdecl;{$endif} {$ifdef mswindows}stdcall;{$endif}
var tsrGetPlayerInfoByName : TtsrGetPlayerInfoByName;
Const fn_tsrGetPlayerInfoByName='tsrGetPlayerInfoByName';
//##############################################################################
//#
//# Function tsrGetChannels( tsrChannels : PtsrChannelInfo;
//# ChannelRecords: PInteger): Integer;
//#
//# Description:
//# Get a list of the channels on the server.
//#
//# Input:
//# tsrChannels: A pointer to an array of TtsrChannelInfo records
//# ChannelRecords: pointer to a integer which specifies how many
//# TtsrChannelInfo records tsrChannels can hold.
//#
//# Output:
//# Result: 0 = OK, else the error number
//# if result = 0 then tsrChannels is filled with the channel info.
//# ChannelRecords will have the number or records that were filled
//#
//##############################################################################
type TtsrGetChannels = Function ( tsrChannels : PtsrChannelInfo; ChannelRecords: PInteger): Integer;
{$ifdef linux}cdecl;{$endif} {$ifdef mswindows}stdcall;{$endif}
var tsrGetChannels : TtsrGetChannels;
Const fn_tsrGetChannels='tsrGetChannels';
//##############################################################################
//#
//# Function tsrGetPlayers( tsrPlayers: PtsrPlayerInfo;
//# PlayerRecords: PInteger): Integer;
//#
//# Description:
//# Get a list of the Players on the server.
//#
//# Input:
//# tsrPlayers: A pointer to an array of TtsrPlayerInfo records
//# PlayerRecords: pointer to a integer which specifies how many
//# TtsrPlayerInfo records tsrPlayers can hold.
//#
//# Output:
//# Result: 0 = OK, else the error number
//# if result = 0 then tsrPlayers is filled with the Player info.
//# PlayerRecords will have the number or records that were filled
//#
//##############################################################################
type TtsrGetPlayers = Function ( tsrPlayers: PtsrPlayerInfo; PlayerRecords: PInteger): Integer;
{$ifdef linux}cdecl;{$endif} {$ifdef mswindows}stdcall;{$endif}
var tsrGetPlayers : TtsrGetPlayers;
Const fn_tsrGetPlayers='tsrGetPlayers';
//##############################################################################
//#
//# Function tsrGetSpeakers( IDs : PInteger; RecordCount: PInteger): Integer;
//#
//# Description:
//# Get ID list of people that are speaking now
//#
//# Input:
//# IDs: Buffer to hold atleast RecordCount Integers
//# RecordCount: How much Integers IDs can hold
//#
//# Output:
//# Result: 0 = OK, else the error number
//# if result = 0 then
//# IDs: Buffer to RecordCount* Ids of people who are talking
//# RecordCount: How Much people are talking
//#
//##############################################################################
Type TtsrGetSpeakers = Function ( IDs : PInteger; RecordCount: PInteger): Integer;
{$ifdef linux}cdecl;{$endif} {$ifdef mswindows}stdcall;{$endif}
var tsrGetSpeakers : TtsrGetSpeakers;
Const fn_tsrGetSpeakers='tsrGetSpeakers';
//##############################################################################
//#
//# Function tsrSetPlayerFlags( tsrPlayerFlags : Integer ): Integer;
//#
//# Description:
//# Set player flags of the user
//#
//# Input:
//# tsrPlayerFlags: An integer wich has the bitmask for all the flags
//# All flags are set to this bitmask.
//#
//# Output:
//# Result: 0 = OK, else the error number
//#
//##############################################################################
type TtsrSetPlayerFlags = Function ( tsrPlayerFlags : Integer ): Integer;
{$ifdef linux}cdecl;{$endif} {$ifdef mswindows}stdcall;{$endif}
var tsrSetPlayerFlags : TtsrSetPlayerFlags;
Const fn_tsrSetPlayerFlags='tsrSetPlayerFlags';
//##############################################################################
//#
//# Function tsrSetWantVoiceReason( tsrReason: pchar ):Integer;
//#
//# Description:
//# set the reason you want voice on a channel
//#
//# Input:
//# tsrReason: The reseason for voice
//#
//# Output:
//# Result: 0 = OK, else the error number
//#
//##############################################################################
type TtsrSetWantVoiceReason = Function ( tsrReason: pchar ):Integer;
{$ifdef linux}cdecl;{$endif} {$ifdef mswindows}stdcall;{$endif}
var tsrSetWantVoiceReason : TtsrSetWantVoiceReason;
Const fn_tsrSetWantVoiceReason='tsrSetWantVoiceReason';
//##############################################################################
//#
//# Function tsrSetOperator( PlayerID: Integer; GrantRevoke: Integer ):Integer;
//#
//# Description:
//# Grant or revoke Operator status
//#
//# Input:
//# PlayerID: ID of the player to set the operator status for
//# GrantRevoke: Set to grGrant to grant or grRevoke to revoke the privilege
//#
//# Output:
//# Result: 0 = OK, else the error number
//#
//##############################################################################
type TtsrSetOperator = Function ( PlayerID: Integer; GrantRevoke: Integer ):Integer;
{$ifdef linux}cdecl;{$endif} {$ifdef mswindows}stdcall;{$endif}
var tsrSetOperator : TtsrSetOperator;
Const fn_tsrSetOperator='tsrSetOperator';
//##############################################################################
//#
//# Function tsrSetVoice( PlayerID: Integer; GrantRevoke: Integer ):Integer;
//#
//# Description:
//# Grant or revoke Voice status
//#
//# Input:
//# PlayerID: ID of the player to set the Voice status for
//# GrantRevoke: Set to grGrant to grant or grRevoke to revoke the privilege
//#
//# Output:
//# Result: 0 = OK, else the error number
//#
//##############################################################################
Type TtsrSetVoice = Function ( PlayerID: Integer; GrantRevoke: Integer ):Integer;
{$ifdef linux}cdecl;{$endif} {$ifdef mswindows}stdcall;{$endif}
var tsrSetVoice : TtsrSetVoice;
Const fn_tsrSetVoice='tsrSetVoice';
//##############################################################################
//#
//# Function tsrKickPlayerFromServer( PlayerID: Integer;
//# Reason : Pchar ):Integer;
//#
//# Description:
//# Kick a player from the server;
//#
//# Input:
//# PlayerID: ID of the player to set the Voice status for
//# Reason: The reason why he was kicked
//#
//# Output:
//# Result: 0 = OK, else the error number
//#
//##############################################################################
type TtsrKickPlayerFromServer = Function ( PlayerID: Integer; Reason : Pchar ):Integer;
{$ifdef linux}cdecl;{$endif} {$ifdef mswindows}stdcall;{$endif}
var tsrKickPlayerFromServer : TtsrKickPlayerFromServer;
Const fn_tsrKickPlayerFromServer='tsrKickPlayerFromServer';
//##############################################################################
//#
//# Function tsrKickPlayerFromChannel( PlayerID: Integer;
//# Reason : Pchar ):Integer;
//#
//# Description:
//# Kick a player from the Channel;
//#
//# Input:
//# PlayerID: ID of the player to set the Voice status for
//# Reason: The reason why he was kicked
//#
//# Output:
//# Result: 0 = OK, else the error number
//#
//##############################################################################
type TtsrKickPlayerFromChannel = Function ( PlayerID: Integer; Reason : Pchar ):Integer;
{$ifdef linux}cdecl;{$endif} {$ifdef mswindows}stdcall;{$endif}
var tsrKickPlayerFromChannel : TtsrKickPlayerFromChannel;
Const fn_tsrKickPlayerFromChannel='tsrKickPlayerFromChannel';
//##############################################################################
//#
//# Function tsrSendTextMessageToChannel( ChannelID: Integer;
//# Message : Pchar ):Integer;
//#
//# Description:
//# Send a text message to a channel
//#
//# Input:
//# ChannelID: The ID of the channel you want to send the txt message to
//# Message : The message you want to send.
//#
//# Output:
//# Result: 0 = OK, else the error number
//#
//##############################################################################
Type TtsrSendTextMessageToChannel = Function ( ChannelID: Integer; Message : Pchar ):Integer;
{$ifdef linux}cdecl;{$endif} {$ifdef mswindows}stdcall;{$endif}
var tsrSendTextMessageToChannel : TtsrSendTextMessageToChannel;
Const fn_tsrSendTextMessageToChannel='tsrSendTextMessageToChannel';
//##############################################################################
//#
//# Function tsrSendTextMessage( Message : Pchar ):Integer;
//#
//# Description:
//# Send a text message to everyone
//#
//# Input:
//# Message : The message you want to send.
//#
//# Output:
//# Result: 0 = OK, else the error number
//#
//##############################################################################
Type TtsrSendTextMessage = Function ( Message : Pchar ):Integer;
{$ifdef linux}cdecl;{$endif} {$ifdef mswindows}stdcall;{$endif}
var tsrSendTextMessage : TtsrSendTextMessage;
Const fn_tsrSendTextMessage='tsrSendTextMessage';
implementation
{$ifdef mswindows}
uses windows, SysUtils;
{$endif}
{$ifdef LINUX}
uses Libc, SysUtils;
{$endif}
Var Handle : Integer = 0;
Function GetAddress(Handle: Integer; Const FunctionName: PChar):Pointer;
begin
{$Ifdef mswindows}Result := GetProcAddress(Handle, FunctionName);{$Endif}
{$Ifdef linux}Result := dlsym(pointer(Handle), FunctionName);{$Endif};
end;
Function GetHandle( Name : Pchar ): Integer;
begin
{$ifdef mswindows}
Result := LoadLibrary(Name);
{$endif}
{$ifdef linux}
Result := integer(dlopen(Name,RTLD_NOW));
{$endif}
end;
Function InitTsRemoteLibrary(TryLocal: Boolean): Integer;
var
LocalName : String;
begin
if handle <> 0 then
begin
Result := -1;
Exit;
end;
if TryLocal then
begin
LocalName := ExtractFilePath(ParamStr(0))+LibName;
handle := GetHandle(pchar(LocalName));
if Handle = 0 then handle := GetHandle(LibName);
end
else handle := GetHandle(LibName);
if handle = 0 then
begin
Result := -2;
exit;
end;
result := -3;
@tsrGetLastError := GetAddress(Handle, fn_tsrGetLastError);
if not assigned(tsrGetLastError ) then exit;
@tsrConnect := GetAddress(Handle, fn_tsrConnect);
if not assigned(tsrConnect) then exit;
@tsrDisconnect := GetAddress(Handle, fn_tsrDisconnect);
if not assigned(tsrDisconnect) then exit;
@tsrQuit := GetAddress(Handle, fn_tsrQuit);
if not assigned(tsrQuit) then exit;
@tsrSwitchChannelName := GetAddress(Handle, fn_tsrSwitchChannelName);
if not assigned(tsrSwitchChannelName) then exit;
@tsrSwitchChannelID := GetAddress(Handle, fn_tsrSwitchChannelID);
if not assigned(tsrSwitchChannelID ) then exit;
@tsrGetVersion := GetAddress(Handle, fn_tsrGetVersion);
if not assigned(tsrGetVersion) then exit;
@tsrGetServerInfo := GetAddress(Handle, fn_tsrGetServerInfo);
if not assigned(tsrGetServerInfo) then exit;
@tsrGetUserInfo := GetAddress(Handle, fn_tsrGetUserInfo);
if not assigned(tsrGetUserInfo) then exit;
@tsrGetChannelInfoByID := GetAddress(Handle, fn_tsrGetChannelInfoByID);
if not assigned(tsrGetChannelInfoByID) then exit;
@tsrGetChannelInfoByName := GetAddress(Handle, fn_tsrGetChannelInfoByName);
if not assigned(tsrGetChannelInfoByName) then exit;
@tsrGetPlayerInfoByID := GetAddress(Handle, fn_tsrGetPlayerInfoByID);
if not assigned(tsrGetPlayerInfoByID) then exit;
@tsrGetPlayerInfoByName := GetAddress(Handle, fn_tsrGetPlayerInfoByName);
if not assigned(tsrGetPlayerInfoByName) then exit;
@tsrGetChannels := GetAddress(Handle, fn_tsrGetChannels);
if not assigned(tsrGetChannels) then exit;
@tsrGetPlayers := GetAddress(Handle, fn_tsrGetPlayers);
if not assigned(tsrGetPlayers) then exit;
@tsrGetSpeakers := GetAddress(Handle, fn_tsrGetSpeakers);
if not assigned(tsrGetSpeakers) then exit;
@tsrSetPlayerFlags := GetAddress(Handle, fn_tsrSetPlayerFlags);
if not assigned(tsrSetPlayerFlags) then exit;
@tsrSetWantVoiceReason := GetAddress(Handle, fn_tsrSetWantVoiceReason);
if not assigned(tsrSetWantVoiceReason) then exit;
@tsrSetOperator := GetAddress(Handle, fn_tsrSetOperator);
if not assigned(tsrSetOperator) then exit;
@tsrSetVoice := GetAddress(Handle, fn_tsrSetVoice);
if not assigned(tsrSetVoice) then exit;
@tsrKickPlayerFromServer := GetAddress(Handle, fn_tsrKickPlayerFromServer);
if not assigned(tsrKickPlayerFromServer) then exit;
@tsrKickPlayerFromChannel := GetAddress(Handle, fn_tsrKickPlayerFromChannel);
if not assigned(tsrKickPlayerFromChannel) then exit;
@tsrSendTextMessageToChannel := GetAddress(Handle, fn_tsrSendTextMessageToChannel);
if not assigned(tsrSendTextMessageToChannel) then exit;
@tsrSendTextMessage := GetAddress(Handle, fn_tsrSendTextMessage);
if not assigned(tsrSendTextMessage) then exit;
result := 0;
end;
Function CloseTsRemoteLibrary: Integer;
begin
if handle = 0 then
begin
Result := -1;
Exit;
end;
try
{$ifdef mswindows}
FreeLibrary(Handle);
{$endif}
{$ifdef linux}
dlclose(pointer(Handle));
{$endif}
Handle := 0;
Result := 0;
Except
Handle := 0;
Result := -2;
end;
end;
end.
|