unit COMPresence;
{
    Copyright 2003, Peter Millard

    This file is part of Exodus.

    Exodus is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    Exodus is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Exodus; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
}

{$WARN SYMBOL_PLATFORM OFF}

interface

uses
  Presence, ComObj, ActiveX, AnyQCOM_TLB, StdVcl;

type
  TAnyQPresence = class(TAutoObject, IAnyQPresence)
  protected
    function Get_ErrorString: WideString; safecall;
    function Get_PresType: WideString; safecall;
    function Get_Priority: Integer; safecall;
    function Get_Show: WideString; safecall;
    function Get_Status: WideString; safecall;
    function XML: WideString; safecall;
    function isSubscription: WordBool; safecall;
    procedure Set_ErrorString(const Value: WideString); safecall;
    procedure Set_PresType(const Value: WideString); safecall;
    procedure Set_Priority(Value: Integer); safecall;
    procedure Set_Show(const Value: WideString); safecall;
    procedure Set_Status(const Value: WideString); safecall;
    function Get_fromJid: WideString; safecall;
    function Get_toJid: WideString; safecall;
    procedure Set_fromJid(const Value: WideString); safecall;
    procedure Set_toJid(const Value: WideString); safecall;
    { Protected declarations }
  private
    _p: TJabberPres;
  public
    constructor Create(p: TJabberPres);
  end;

implementation

uses
  JabberID, ComServ;

{---------------------------------------}

constructor TAnyQPresence.Create(p: TJabberPres);
begin
  _p := p;
end;

{---------------------------------------}

function TAnyQPresence.Get_ErrorString: WideString;
begin
  Result := _p.error_code;
end;

{---------------------------------------}

function TAnyQPresence.Get_PresType: WideString;
begin
  Result := _p.PresType;
end;

{---------------------------------------}

function TAnyQPresence.Get_Priority: Integer;
begin
  Result := _p.Priority;
end;

{---------------------------------------}

function TAnyQPresence.Get_Show: WideString;
begin
  Result := _p.Show;
end;

{---------------------------------------}

function TAnyQPresence.Get_Status: WideString;
begin
  Result := _p.Status;
end;

{---------------------------------------}

function TAnyQPresence.XML: WideString;
begin
  Result := _p.xml();
end;

{---------------------------------------}

function TAnyQPresence.isSubscription: WordBool;
begin
  Result := _p.isSubscription();
end;

{---------------------------------------}

procedure TAnyQPresence.Set_ErrorString(const Value: WideString);
begin
  _p.error_code := Value;
end;

{---------------------------------------}

procedure TAnyQPresence.Set_PresType(const Value: WideString);
begin
  _p.PresType := Value;
end;

{---------------------------------------}

procedure TAnyQPresence.Set_Priority(Value: Integer);
begin
  _p.Priority := Value;
end;

{---------------------------------------}

procedure TAnyQPresence.Set_Show(const Value: WideString);
begin
  _p.Show := Value;
end;

{---------------------------------------}

procedure TAnyQPresence.Set_Status(const Value: WideString);
begin
  _p.Status := Value;
end;

{---------------------------------------}

function TAnyQPresence.Get_fromJid: WideString;
begin
  Result := _p.fromJid.full();
end;

{---------------------------------------}

function TAnyQPresence.Get_toJid: WideString;
begin
  Result := _p.toJid.full();
end;

{---------------------------------------}

procedure TAnyQPresence.Set_fromJid(const Value: WideString);
var
  tmpjid: TJabberID;
begin
  tmpjid := TJabberID.Create(Value);
  _p.fromJid := tmpjid;
end;

{---------------------------------------}

procedure TAnyQPresence.Set_toJid(const Value: WideString);
var
  tmpjid: TJabberID;
begin
  tmpjid := TJabberID.Create(value);
  _p.toJid := tmpjid;
end;

initialization
  TAutoObjectFactory.Create(ComServer, TAnyQPresence, Class_AnyQPresence,
    ciMultiInstance, tmApartment);
end.
