1. -- 
  2. --  Copyright (c) 2008-2009, 
  3. --  Reto Buerki, Adrian-Ken Rueegsegger 
  4. --  secunet SwissIT AG 
  5. -- 
  6. --  This file is part of Alog. 
  7. -- 
  8. --  Alog is free software; you can redistribute it and/or modify 
  9. --  it under the terms of the GNU Lesser General Public License as published 
  10. --  by the Free Software Foundation; either version 2.1 of the License, or 
  11. --  (at your option) any later version. 
  12. -- 
  13. --  Alog is distributed in the hope that it will be useful, 
  14. --  but WITHOUT ANY WARRANTY; without even the implied warranty of 
  15. --  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
  16. --  GNU Lesser General Public License for more details. 
  17. -- 
  18. --  You should have received a copy of the GNU Lesser General Public License 
  19. --  along with Alog; if not, write to the Free Software 
  20. --  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, 
  21. --  MA  02110-1301  USA 
  22.  
  23. --  XMPP-Logging (jabber) facility. 
  24. --  Send log-messages to a configured Jabber ID via a given jabber server. 
  25. --  AWS must be installed for this facility to work. 
  26. package Alog.Facilities.XMPP is 
  27.  
  28.    type Instance is new Alog.Facilities.Instance with private; 
  29.    --  XMPP based logging facility. 
  30.  
  31.    type Handle is access all Instance; 
  32.  
  33.    procedure Set_Sender 
  34.      (Facility : in out Instance; 
  35.       JID      :        String; 
  36.       Password :        String); 
  37.    --  Set sender for log messages. This procedure MUST be called before 
  38.    --  subsequent calls to Write_Message(). 
  39.  
  40.    procedure Set_Recipient 
  41.      (Facility : in out Instance; 
  42.       JID      :        String); 
  43.    --  Set recipient for log-messages. This procedure MUST be called before 
  44.    --  subsequent calls to Write_Message(). 
  45.  
  46.    procedure Set_Server 
  47.      (Facility : in out Instance; 
  48.       Name     :        String); 
  49.    --  Set server for log-messages. This procedure MUST be called before 
  50.    --  subsequent calls to Write_Message(). 
  51.  
  52.    No_Sender             : exception; 
  53.    --  No sender ID specified. Cannot send message. 
  54.  
  55.    No_Recipient          : exception; 
  56.    --  No recipient specified. Cannot send message. 
  57.  
  58.    No_Server             : exception; 
  59.    --  No server specified. Cannot send message. 
  60.  
  61.    Recipient_Not_Present : exception; 
  62.    --  Recipient can not be reached through specified server. 
  63.  
  64.    Delivery_Failed       : exception; 
  65.    --  Message could not be delivered. 
  66.  
  67. private 
  68.  
  69.    overriding 
  70.    procedure Write 
  71.      (Facility : Instance; 
  72.       Level    : Log_Level := Info; 
  73.       Msg      : String); 
  74.    --  Implementation of the Write procedure for XMPP. 
  75.  
  76.    type Sender_Account is tagged 
  77.       record 
  78.          JID      : Unbounded_String; 
  79.          Password : Unbounded_String; 
  80.       end record; 
  81.    --  Holds sender information. 
  82.  
  83.    type Instance is new Alog.Facilities.Instance with record 
  84.       Sender       : Sender_Account := 
  85.         (JID      => To_Unbounded_String ("alog@localhost"), 
  86.          Password => To_Unbounded_String ("")); 
  87.       --  Notification sender JID/password. 
  88.  
  89.       Is_Sender    : Boolean := False; 
  90.       --  Indicates whether sender id is set. 
  91.  
  92.       Server       : Unbounded_String; 
  93.       --  Server to connect to. 
  94.  
  95.       Is_Server    : Boolean := False; 
  96.       --  Indicates whether a server is set. 
  97.  
  98.       Recipient    : Unbounded_String; 
  99.       --  Recipient for log-mails. Must be specified before calling 
  100.       --  Write_Message(), else No_Recipient exception is thrown. 
  101.  
  102.       Is_Recipient : Boolean := False; 
  103.       --  Indicates whether a recipient is set. 
  104.  
  105.       Subject      : Unbounded_String := 
  106.         To_Unbounded_String ("Alog: Log-Message"); 
  107.       --  Subject of messages from Alog-System (default: Alog: Log-Message). 
  108.    end record; 
  109.  
  110. end Alog.Facilities.XMPP;