unit COMPPDB;
{
    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
  ComObj, ActiveX, AnyQCOM_TLB, StdVcl;

type
  TAnyQPPDB = class(TAutoObject, IAnyQPPDB)
  protected
    function Find(const JabberID, Resource: WideString): IAnyQPresence;
      safecall;
    function Next(const JabberID, Resource: WideString): IAnyQPresence;
      safecall;
    function Get_Count: Integer; safecall;
    function Get_LastPresence: IAnyQPresence; safecall;
    { Protected declarations }
  end;

{---------------------------------------}
{---------------------------------------}
{---------------------------------------}
implementation

uses
  COMPresence, Presence, Session, ComServ;

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

function TAnyQPPDB.Find(const JabberID,
  Resource: WideString): IAnyQPresence;
var
  p: TJabberPres;
begin
  p := MainSession.ppdb.FindPres(JabberID, Resource);
  if (p <> nil) then
    Result := TAnyQPresence.Create(p)
  else
    Result := nil;
end;

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

function TAnyQPPDB.Next(const JabberID,
  Resource: WideString): IAnyQPresence;
var
  p: TJabberPres;
begin
  p := MainSession.ppdb.Findpres(JabberID, Resource);
  p := MainSession.ppdb.NextPres(p);
  if (p <> nil) then
    Result := TAnyQPresence.Create(p)
  else
    Result := nil;
end;

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

function TAnyQPPDB.Get_Count: Integer;
begin
  Result := MainSession.ppdb.Count;
end;

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

function TAnyQPPDB.Get_LastPresence: IAnyQPresence;
var
  p: TJabberPres;
begin
  p := mainSession.ppdb.LastPres;
  if (p <> nil) then
    Result := TAnyQPresence(p)
  else
    Result := nil;
end;

initialization
  TAutoObjectFactory.Create(ComServer, TAnyQPPDB, Class_AnyQPPDB,
    ciMultiInstance, tmApartment);
end.
