29 using System.Collections.Generic;
31 using System.Reflection;
32 using System.Runtime.Serialization;
36 using System.Xml.Serialization;
42 using OpenSim.Framework;
43 using OpenSim.Services.Interfaces;
45 namespace OpenSim.OfflineIM
50 private const int MAX_IM = 25;
52 private XmlSerializer m_serializer;
53 private static bool m_Initialized =
false;
61 m_Database.DeleteOld();
68 List<GridInstantMessage> ims =
new List<GridInstantMessage>();
70 OfflineIMData[] messages = m_Database.Get(
"PrincipalID", principalID.ToString());
72 if (messages == null || (messages != null && messages.Length == 0))
77 using (MemoryStream mstream =
new MemoryStream(Encoding.UTF8.GetBytes(m.
Data[
"Message"])))
85 m_Database.Delete(
"PrincipalID", principalID.ToString());
92 reason = string.Empty;
95 UUID principalID =
new UUID(im.
toAgentID);
96 long count = m_Database.GetCount(
"PrincipalID", principalID.ToString());
99 reason =
"Number of offline IMs has maxed out";
104 using (MemoryStream mstream =
new MemoryStream())
106 XmlWriterSettings settings =
new XmlWriterSettings();
107 settings.Encoding = Util.UTF8NoBomEncoding;
109 using (XmlWriter writer = XmlWriter.Create(mstream, settings))
111 m_serializer.Serialize(writer, im);
115 imXml = Util.UTF8NoBomEncoding.GetString(mstream.ToArray());
119 data.PrincipalID = principalID;
121 data.Data =
new Dictionary<string, string>();
122 data.Data[
"Message"] = imXml;
124 return m_Database.Store(data);
130 m_Database.Delete(
"PrincipalID", userID.ToString());
131 m_Database.Delete(
"FromID", userID.ToString());
List< GridInstantMessage > GetMessages(UUID principalID)
void DeleteMessages(UUID userID)
Delete messages to or from this user (or group).
bool StoreMessage(GridInstantMessage im, out string reason)
OfflineIMService(IConfigSource config)
Dictionary< string, string > Data