unit DockableEX;

interface

uses
  XMLTAG, Presence,
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Dockable;

type
  TfrmDockableEx = class(TfrmDockable)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
    _pcallback: integer; // presence callback id
    _scallback: integer; // session callback id
  public
    { Public declarations }
    procedure PresCallback(event: string; tag: TXMLTag; p: TJabberPres); virtual;
    procedure SessionCallback(event: string; tag: TXMLTag); virtual;
  end;

var
  frmDockableEx: TfrmDockableEx;

implementation

uses Session, ExSession;

{$R *.dfm}

procedure TfrmDockableEx.FormCreate(Sender: TObject);
begin
  inherited;
  _pcallback := MainSession.RegisterCallback(PresCallback);
  _scallback := MainSession.RegisterCallback(SessionCallback, '/session');
end;

procedure TfrmDockableEx.FormDestroy(Sender: TObject);
begin
  if (MainSession <> nil) then begin
    MainSession.UnRegisterCallback(_pcallback);
    MainSession.UnRegisterCallback(_scallback);
  end;
  inherited;
end;

procedure TfrmDockableEx.PresCallback(event: string; tag: TXMLTag;
  p: TJabberPres);
begin
end;

procedure TfrmDockableEx.SessionCallback(event: string; tag: TXMLTag);
begin
  if (event = '/session/disconnected') then
  begin
    Close;
  end
end;

end.
