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