diff options
author | Melanie Thielker | 2009-03-28 02:58:12 +0000 |
---|---|---|
committer | Melanie Thielker | 2009-03-28 02:58:12 +0000 |
commit | 0ff7c85a5d2127657546f37fe53b02c955e493d4 (patch) | |
tree | e3c83a9149c761ed403ebd3a3067a6a90fbec79c | |
parent | * Remove redundancies in ScenePresence (diff) | |
download | opensim-SC_OLD-0ff7c85a5d2127657546f37fe53b02c955e493d4.zip opensim-SC_OLD-0ff7c85a5d2127657546f37fe53b02c955e493d4.tar.gz opensim-SC_OLD-0ff7c85a5d2127657546f37fe53b02c955e493d4.tar.bz2 opensim-SC_OLD-0ff7c85a5d2127657546f37fe53b02c955e493d4.tar.xz |
Add a module skeleton for offline IM storage. No functionality yet.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs | 131 | ||||
-rw-r--r-- | bin/OpenSim.ini.example | 3 |
2 files changed, 134 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs new file mode 100644 index 0000000..d09c669 --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs | |||
@@ -0,0 +1,131 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using System.Collections.Generic; | ||
28 | using System.Reflection; | ||
29 | using log4net; | ||
30 | using Nini.Config; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Framework.Client; | ||
34 | using OpenSim.Region.Framework.Interfaces; | ||
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | |||
37 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | ||
38 | { | ||
39 | public class OfflineMessageModule : IRegionModule | ||
40 | { | ||
41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
42 | |||
43 | private bool enabled = false; | ||
44 | private List<Scene> m_SceneList = new List<Scene>(); | ||
45 | |||
46 | public void Initialise(Scene scene, IConfigSource config) | ||
47 | { | ||
48 | IConfig cnf = config.Configs["Messaging"]; | ||
49 | if (cnf != null && cnf.GetString( | ||
50 | "OfflineMessageModule", "None") != | ||
51 | "OfflineMessageModule") | ||
52 | return; | ||
53 | |||
54 | enabled = true; | ||
55 | |||
56 | lock (m_SceneList) | ||
57 | { | ||
58 | if (m_SceneList.Count == 0) | ||
59 | { | ||
60 | IMessageTransferModule trans = scene.RequestModuleInterface<IMessageTransferModule>(); | ||
61 | if (trans == null) | ||
62 | { | ||
63 | enabled = false; | ||
64 | return; | ||
65 | } | ||
66 | |||
67 | trans.OnUndeliveredMessage += UndeliveredMessage; | ||
68 | } | ||
69 | |||
70 | if (!m_SceneList.Contains(scene)) | ||
71 | m_SceneList.Add(scene); | ||
72 | |||
73 | scene.EventManager.OnNewClient += OnNewClient; | ||
74 | } | ||
75 | } | ||
76 | |||
77 | public void PostInitialise() | ||
78 | { | ||
79 | } | ||
80 | |||
81 | public string Name | ||
82 | { | ||
83 | get { return "OfflineMessageModule"; } | ||
84 | } | ||
85 | |||
86 | public bool IsSharedModule | ||
87 | { | ||
88 | get { return true; } | ||
89 | } | ||
90 | |||
91 | public void Close() | ||
92 | { | ||
93 | } | ||
94 | |||
95 | private IClientAPI FindClient(UUID agentID) | ||
96 | { | ||
97 | foreach (Scene s in m_SceneList) | ||
98 | { | ||
99 | ScenePresence presence = s.GetScenePresence(agentID); | ||
100 | if (!presence.IsChildAgent) | ||
101 | return presence.ControllingClient; | ||
102 | } | ||
103 | return null; | ||
104 | } | ||
105 | |||
106 | private void OnNewClient(IClientAPI client) | ||
107 | { | ||
108 | client.OnRetrieveInstantMessages += RetrieveInstantMessages; | ||
109 | } | ||
110 | |||
111 | private void RetrieveInstantMessages(IClientAPI client) | ||
112 | { | ||
113 | m_log.Debug("[OFFLINE MESSAGING] RetrieveInstantMessages called"); | ||
114 | } | ||
115 | |||
116 | private void UndeliveredMessage(GridInstantMessage im) | ||
117 | { | ||
118 | IClientAPI client = FindClient(new UUID(im.toAgentID)); | ||
119 | if (client == null) | ||
120 | return; | ||
121 | |||
122 | client.SendInstantMessage(new UUID(im.toAgentID), | ||
123 | "User is not logged in. "+ | ||
124 | "Message saved.", | ||
125 | new UUID(im.fromAgentID), "System", | ||
126 | (byte)InstantMessageDialog.BusyAutoResponse, | ||
127 | (uint)Util.UnixTimeSinceEpoch()); | ||
128 | } | ||
129 | } | ||
130 | } | ||
131 | |||
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 9f5932a..64cf4e5 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example | |||
@@ -375,6 +375,9 @@ InterregionComms = "RESTComms" | |||
375 | ; Control which region module is used for instant messaging. | 375 | ; Control which region module is used for instant messaging. |
376 | ; Default is InstantMessageModule (this is the name of the core IM module as well as the setting) | 376 | ; Default is InstantMessageModule (this is the name of the core IM module as well as the setting) |
377 | InstantMessageModule = InstantMessageModule | 377 | InstantMessageModule = InstantMessageModule |
378 | ; MessageTransferModule = MessageTransferModule | ||
379 | ; OfflineMessageModule = OfflineMessageModule | ||
380 | ; OfflineMessagesURL = http://yourserver/offlines.php | ||
378 | 381 | ||
379 | 382 | ||
380 | [ODEPhysicsSettings] | 383 | [ODEPhysicsSettings] |