28 using System.Collections.Generic;
 
   29 using System.Reflection;
 
   34 using OpenSim.Framework;
 
   35 using OpenSim.Framework.Servers;
 
   36 using OpenSim.Framework.Client;
 
   37 using OpenSim.Region.Framework.Interfaces;
 
   38 using OpenSim.Region.Framework.Scenes;
 
   40 namespace OpenSim.
Region.CoreModules.
Avatar.InstantMessage
 
   49     [Extension(Path = 
"/OpenSim/RegionModules", NodeName = 
"RegionModule", Id = 
"OfflineMessageModule")]
 
   52         private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
 
   54         private bool enabled = 
true;
 
   55         private List<Scene> m_SceneList = 
new List<Scene>();
 
   56         private string m_RestURL = String.Empty;
 
   58         private bool m_ForwardOfflineGroupMessages = 
true;
 
   59         private Dictionary<IClientAPI, List<UUID>> m_repliesSent= 
new Dictionary<IClientAPI, List<UUID>>();
 
   63             IConfig cnf = config.Configs[
"Messaging"];
 
   69             if (cnf != null && cnf.GetString(
"OfflineMessageModule", 
"None") !=
 
   70                     "OfflineMessageModule")
 
   76             m_RestURL = cnf.GetString(
"OfflineMessageURL", 
"");
 
   79                 m_log.Error(
"[OFFLINE MESSAGING] Module was enabled, but no URL is given, disabling");
 
   84             m_ForwardOfflineGroupMessages = cnf.GetBoolean(
"ForwardOfflineGroupMessages", m_ForwardOfflineGroupMessages);
 
   94                 m_SceneList.Add(scene);
 
   96                 scene.EventManager.OnNewClient += OnNewClient;
 
  105             if (m_TransferModule == null)
 
  108                 if (m_TransferModule == null)
 
  110                     scene.EventManager.OnNewClient -= OnNewClient;
 
  115                     m_log.Error(
"[OFFLINE MESSAGING] No message transfer module is enabled. Diabling offline messages");
 
  128                 m_SceneList.Remove(scene);
 
  137             m_log.Debug(
"[OFFLINE MESSAGING] Offline messages enabled");
 
  142             get { 
return "OfflineMessageModule"; }
 
  145         public Type ReplaceableInterface
 
  154         private Scene FindScene(UUID agentID)
 
  156             foreach (
Scene s 
in m_SceneList)
 
  167             foreach (
Scene s 
in m_SceneList)
 
  171                     return presence.ControllingClient;
 
  179             client.OnLogout += OnClientLoggedOut;
 
  184             m_repliesSent.Remove(client);
 
  189             if (m_RestURL == 
String.Empty)
 
  195                 m_log.DebugFormat(
"[OFFLINE MESSAGING]: Retrieving stored messages for {0}", client.AgentId);
 
  197                 List<GridInstantMessage> msglist
 
  198                     = SynchronousRestObjectRequester.MakeRequest<
UUID, List<GridInstantMessage>>(
 
  199                         "POST", m_RestURL + 
"/RetrieveMessages/", client.AgentId);
 
  205                         if (im.
dialog == (byte)InstantMessageDialog.InventoryOffered)
 
  221                                 s.EventManager.TriggerIncomingInstantMessage(im);
 
  230             if (im.
dialog != (byte)InstantMessageDialog.MessageFromObject &&
 
  231                 im.
dialog != (byte)InstantMessageDialog.MessageFromAgent &&
 
  232                 im.
dialog != (byte)InstantMessageDialog.GroupNotice &&
 
  233                 im.
dialog != (byte)InstantMessageDialog.GroupInvitation &&
 
  234                 im.
dialog != (byte)InstantMessageDialog.InventoryOffered &&
 
  235                 im.
dialog != (byte)InstantMessageDialog.TaskInventoryOffered)
 
  240             if (!m_ForwardOfflineGroupMessages)
 
  242                 if (im.
dialog == (byte)InstantMessageDialog.GroupNotice ||
 
  243                     im.
dialog == (byte)InstantMessageDialog.GroupInvitation)
 
  249                 scene = m_SceneList[0];
 
  258                     "POST", m_RestURL+
"/SaveMessage/", im, 10000);
 
  261             if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
 
  263                 IClientAPI client = FindClient(
new UUID(im.fromAgentID));
 
  301                 client.SendInstantMessage(
new GridInstantMessage(
 
  302                         null, 
new UUID(im.toAgentID),
 
  303                         "System", 
new UUID(im.fromAgentID),
 
  304                         (byte)InstantMessageDialog.MessageFromAgent,
 
  305                         "User is not logged in. "+
 
  306                         (success ? 
"Message saved." : 
"Message not saved"),
 
  307                         false, 
new Vector3()));
 
void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...
void PostInitialise()
This is called exactly once after all the shared region-modules have been instanciated and IRegionMod...
delegate void UndeliveredMessage(GridInstantMessage im)
void OnClientLoggedOut(IClientAPI client)
void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
void Initialise(IConfigSource config)
This is called to initialize the region module. For shared modules, this is called exactly once...
void SendInstantMessage(GridInstantMessage im)
delegate void RetrieveInstantMessages(IClientAPI client)