git-svn-id: https://192.168.0.254/svn/Componentes.Terceros.RemObjects@68 b6239004-a887-0f4b-9937-50029ccdca16
91 lines
2.6 KiB
ObjectPascal
91 lines
2.6 KiB
ObjectPascal
unit PairingService_Impl;
|
|
|
|
{----------------------------------------------------------------------------}
|
|
{ This unit was automatically generated by the RemObjects SDK after reading }
|
|
{ the RODL file associated with this project . }
|
|
{ }
|
|
{ This is where you are supposed to code the implementation of your objects. }
|
|
{----------------------------------------------------------------------------}
|
|
|
|
{$I RemObjects.inc}
|
|
|
|
interface
|
|
|
|
uses
|
|
{$IFDEF FPC}LResources,{$ENDIF}
|
|
{vcl:} Classes, SysUtils,
|
|
{RemObjects:} uROXMLIntf, uROClientIntf, uROTypes, uROServer, uROServerIntf, uROSessions,
|
|
{Required:} uRORemoteDataModule,
|
|
{Generated:} PairingLibrary_Intf;
|
|
|
|
type
|
|
{ TPairingService }
|
|
TPairingService = class(TRORemoteDataModule, IPairingService)
|
|
protected
|
|
{ IPairingService methods }
|
|
function LoginAttempt(const ClientGuid: Guid): integer;
|
|
function ConfirmCode(const Code: AnsiString; const ClientGuid: Guid): Boolean;
|
|
end;
|
|
|
|
implementation
|
|
|
|
{$IFNDEF FPC}
|
|
{$R *.dfm}
|
|
{$ENDIF}
|
|
uses
|
|
{Generated:} PairingLibrary_Invk,
|
|
fServerDataModule, ApprovedClientsStorage, PairingStatus, uROClasses,
|
|
fServerForm;
|
|
|
|
procedure Create_PairingService(out anInstance : IUnknown);
|
|
begin
|
|
anInstance := TPairingService.Create(nil);
|
|
end;
|
|
|
|
{ PairingService }
|
|
|
|
function TPairingService.LoginAttempt(const ClientGuid: Guid): integer;
|
|
begin
|
|
if StorageInstance.IsClientKnown(ClientGuid) then begin
|
|
Result := ord(PairingStatus_Successfull);
|
|
Session.Values['OK'] := true;
|
|
end
|
|
else begin
|
|
DestroySession;
|
|
if Pairing.InitiatePairing > 0 then begin
|
|
Result := ord(PairingStatus_PairingRequired);
|
|
ServerForm.DisplayPairingCode(Pairing.Code);
|
|
end
|
|
else Result := ord(PairingStatus_PairingBusy);
|
|
end;
|
|
end;
|
|
|
|
function TPairingService.ConfirmCode(const Code: AnsiString; const ClientGuid: Guid): Boolean;
|
|
var s: string;
|
|
begin
|
|
s := {$IFDEF UNICODE}AnsiStringToWideString{$ENDIF}(Code);
|
|
Result := s = IntToStr(Pairing.Code);
|
|
if Result then begin
|
|
StorageInstance.AddClient(ClientGuid);
|
|
Session.Values['OK'] := true;
|
|
end
|
|
else DestroySession;
|
|
Pairing.CancelPairing;
|
|
ServerForm.HidePairingCode;
|
|
end;
|
|
|
|
var
|
|
fClassFactory: IROClassFactory;
|
|
|
|
initialization
|
|
{$IFDEF FPC}
|
|
{$I PairingService_Impl.lrs}
|
|
{$ENDIF}
|
|
fClassFactory := TROClassFactory.Create('PairingService', Create_PairingService, TPairingService_Invoker);
|
|
RegisterForZeroConf(fClassFactory,'_PairingService_rosdk._tcp.');
|
|
|
|
finalization
|
|
UnRegisterClassFactory(fClassFactory);
|
|
fClassFactory := nil;
|
|
end.
|