diff options
author | Sean Dague | 2007-10-19 20:28:18 +0000 |
---|---|---|
committer | Sean Dague | 2007-10-19 20:28:18 +0000 |
commit | d4bb430f78d9a70137957c8fe42de8fa620597ef (patch) | |
tree | 49612ce0a47acaedfa826d33edbe200c4c2d8b3c /OpenSim/Framework/Communications | |
parent | changes to pass nini config object to the modules that get (diff) | |
download | opensim-SC-d4bb430f78d9a70137957c8fe42de8fa620597ef.zip opensim-SC-d4bb430f78d9a70137957c8fe42de8fa620597ef.tar.gz opensim-SC-d4bb430f78d9a70137957c8fe42de8fa620597ef.tar.bz2 opensim-SC-d4bb430f78d9a70137957c8fe42de8fa620597ef.tar.xz |
get rid of all the ^M line endings
Diffstat (limited to 'OpenSim/Framework/Communications')
-rw-r--r-- | OpenSim/Framework/Communications/Cache/AssetServer.cs | 312 | ||||
-rw-r--r-- | OpenSim/Framework/Communications/Cache/AssetServerBase.cs | 374 | ||||
-rw-r--r-- | OpenSim/Framework/Communications/Cache/SQLAssetServer.cs | 248 | ||||
-rw-r--r-- | OpenSim/Framework/Communications/LoginService.cs | 630 |
4 files changed, 782 insertions, 782 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index b17f65a..22bdc5c 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs | |||
@@ -1,157 +1,157 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.IO; | 30 | using System.IO; |
31 | using System.Threading; | 31 | using System.Threading; |
32 | using Db4objects.Db4o; | 32 | using Db4objects.Db4o; |
33 | using Db4objects.Db4o.Query; | 33 | using Db4objects.Db4o.Query; |
34 | using libsecondlife; | 34 | using libsecondlife; |
35 | using Nini.Config; | 35 | using Nini.Config; |
36 | using OpenSim.Framework.Communications.Cache; | 36 | using OpenSim.Framework.Communications.Cache; |
37 | using OpenSim.Framework.Console; | 37 | using OpenSim.Framework.Console; |
38 | using OpenSim.Framework.Interfaces; | 38 | using OpenSim.Framework.Interfaces; |
39 | using OpenSim.Framework.Types; | 39 | using OpenSim.Framework.Types; |
40 | using OpenSim.Framework.Utilities; | 40 | using OpenSim.Framework.Utilities; |
41 | 41 | ||
42 | namespace OpenSim.Framework.Communications.Cache | 42 | namespace OpenSim.Framework.Communications.Cache |
43 | { | 43 | { |
44 | public class LocalAssetServer : AssetServerBase | 44 | public class LocalAssetServer : AssetServerBase |
45 | { | 45 | { |
46 | private IObjectContainer db; | 46 | private IObjectContainer db; |
47 | 47 | ||
48 | public LocalAssetServer() | 48 | public LocalAssetServer() |
49 | { | 49 | { |
50 | bool yapfile; | 50 | bool yapfile; |
51 | yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap")); | 51 | yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap")); |
52 | 52 | ||
53 | db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap")); | 53 | db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap")); |
54 | MainLog.Instance.Verbose("Db4 Asset database creation"); | 54 | MainLog.Instance.Verbose("Db4 Asset database creation"); |
55 | 55 | ||
56 | if (!yapfile) | 56 | if (!yapfile) |
57 | { | 57 | { |
58 | SetUpAssetDatabase(); | 58 | SetUpAssetDatabase(); |
59 | } | 59 | } |
60 | } | 60 | } |
61 | 61 | ||
62 | public void CreateAndCommitAsset(AssetBase asset) | 62 | public void CreateAndCommitAsset(AssetBase asset) |
63 | { | 63 | { |
64 | AssetStorage store = new AssetStorage(); | 64 | AssetStorage store = new AssetStorage(); |
65 | store.Data = asset.Data; | 65 | store.Data = asset.Data; |
66 | store.Name = asset.Name; | 66 | store.Name = asset.Name; |
67 | store.UUID = asset.FullID; | 67 | store.UUID = asset.FullID; |
68 | db.Set(store); | 68 | db.Set(store); |
69 | db.Commit(); | 69 | db.Commit(); |
70 | } | 70 | } |
71 | 71 | ||
72 | override public void Close() | 72 | override public void Close() |
73 | { | 73 | { |
74 | base.Close(); | 74 | base.Close(); |
75 | 75 | ||
76 | if (db != null) | 76 | if (db != null) |
77 | { | 77 | { |
78 | MainLog.Instance.Verbose("Closing local asset server database"); | 78 | MainLog.Instance.Verbose("Closing local asset server database"); |
79 | db.Close(); | 79 | db.Close(); |
80 | } | 80 | } |
81 | } | 81 | } |
82 | 82 | ||
83 | override protected void RunRequests() | 83 | override protected void RunRequests() |
84 | { | 84 | { |
85 | while (true) | 85 | while (true) |
86 | { | 86 | { |
87 | byte[] idata = null; | 87 | byte[] idata = null; |
88 | bool found = false; | 88 | bool found = false; |
89 | AssetStorage foundAsset = null; | 89 | AssetStorage foundAsset = null; |
90 | ARequest req = this._assetRequests.Dequeue(); | 90 | ARequest req = this._assetRequests.Dequeue(); |
91 | IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); | 91 | IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); |
92 | if (result.Count > 0) | 92 | if (result.Count > 0) |
93 | { | 93 | { |
94 | foundAsset = (AssetStorage)result.Next(); | 94 | foundAsset = (AssetStorage)result.Next(); |
95 | found = true; | 95 | found = true; |
96 | } | 96 | } |
97 | 97 | ||
98 | AssetBase asset = new AssetBase(); | 98 | AssetBase asset = new AssetBase(); |
99 | if (found) | 99 | if (found) |
100 | { | 100 | { |
101 | asset.FullID = foundAsset.UUID; | 101 | asset.FullID = foundAsset.UUID; |
102 | asset.Type = foundAsset.Type; | 102 | asset.Type = foundAsset.Type; |
103 | asset.InvType = foundAsset.Type; | 103 | asset.InvType = foundAsset.Type; |
104 | asset.Name = foundAsset.Name; | 104 | asset.Name = foundAsset.Name; |
105 | idata = foundAsset.Data; | 105 | idata = foundAsset.Data; |
106 | asset.Data = idata; | 106 | asset.Data = idata; |
107 | _receiver.AssetReceived(asset, req.IsTexture); | 107 | _receiver.AssetReceived(asset, req.IsTexture); |
108 | } | 108 | } |
109 | else | 109 | else |
110 | { | 110 | { |
111 | //asset.FullID = ; | 111 | //asset.FullID = ; |
112 | _receiver.AssetNotFound(req.AssetID); | 112 | _receiver.AssetNotFound(req.AssetID); |
113 | } | 113 | } |
114 | 114 | ||
115 | } | 115 | } |
116 | 116 | ||
117 | } | 117 | } |
118 | 118 | ||
119 | override protected void StoreAsset(AssetBase asset) | 119 | override protected void StoreAsset(AssetBase asset) |
120 | { | 120 | { |
121 | AssetStorage store = new AssetStorage(); | 121 | AssetStorage store = new AssetStorage(); |
122 | store.Data = asset.Data; | 122 | store.Data = asset.Data; |
123 | store.Name = asset.Name; | 123 | store.Name = asset.Name; |
124 | store.UUID = asset.FullID; | 124 | store.UUID = asset.FullID; |
125 | db.Set(store); | 125 | db.Set(store); |
126 | 126 | ||
127 | CommitAssets(); | 127 | CommitAssets(); |
128 | } | 128 | } |
129 | 129 | ||
130 | protected override void CommitAssets() | 130 | protected override void CommitAssets() |
131 | { | 131 | { |
132 | db.Commit(); | 132 | db.Commit(); |
133 | } | 133 | } |
134 | 134 | ||
135 | protected virtual void SetUpAssetDatabase() | 135 | protected virtual void SetUpAssetDatabase() |
136 | { | 136 | { |
137 | MainLog.Instance.Verbose("LOCAL ASSET SERVER", "Setting up asset database"); | 137 | MainLog.Instance.Verbose("LOCAL ASSET SERVER", "Setting up asset database"); |
138 | 138 | ||
139 | ForEachDefaultAsset(StoreAsset); | 139 | ForEachDefaultAsset(StoreAsset); |
140 | ForEachXmlAsset(StoreAsset); | 140 | ForEachXmlAsset(StoreAsset); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | public class AssetUUIDQuery : Predicate | 144 | public class AssetUUIDQuery : Predicate |
145 | { | 145 | { |
146 | private LLUUID _findID; | 146 | private LLUUID _findID; |
147 | 147 | ||
148 | public AssetUUIDQuery(LLUUID find) | 148 | public AssetUUIDQuery(LLUUID find) |
149 | { | 149 | { |
150 | _findID = find; | 150 | _findID = find; |
151 | } | 151 | } |
152 | public bool Match(AssetStorage asset) | 152 | public bool Match(AssetStorage asset) |
153 | { | 153 | { |
154 | return (asset.UUID == _findID); | 154 | return (asset.UUID == _findID); |
155 | } | 155 | } |
156 | } | 156 | } |
157 | } \ No newline at end of file | 157 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 858019f..08d5b87 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs | |||
@@ -1,188 +1,188 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.IO; | 3 | using System.IO; |
4 | using System.Threading; | 4 | using System.Threading; |
5 | using libsecondlife; | 5 | using libsecondlife; |
6 | using Nini.Config; | 6 | using Nini.Config; |
7 | using OpenSim.Framework.Console; | 7 | using OpenSim.Framework.Console; |
8 | using OpenSim.Framework.Interfaces; | 8 | using OpenSim.Framework.Interfaces; |
9 | using OpenSim.Framework.Types; | 9 | using OpenSim.Framework.Types; |
10 | using OpenSim.Framework.Utilities; | 10 | using OpenSim.Framework.Utilities; |
11 | 11 | ||
12 | namespace OpenSim.Framework.Communications.Cache | 12 | namespace OpenSim.Framework.Communications.Cache |
13 | { | 13 | { |
14 | public abstract class AssetServerBase : IAssetServer | 14 | public abstract class AssetServerBase : IAssetServer |
15 | { | 15 | { |
16 | protected IAssetReceiver _receiver; | 16 | protected IAssetReceiver _receiver; |
17 | protected BlockingQueue<ARequest> _assetRequests; | 17 | protected BlockingQueue<ARequest> _assetRequests; |
18 | protected Thread _localAssetServerThread; | 18 | protected Thread _localAssetServerThread; |
19 | protected IAssetProvider m_assetProviderPlugin; | 19 | protected IAssetProvider m_assetProviderPlugin; |
20 | protected object syncLock = new object(); | 20 | protected object syncLock = new object(); |
21 | 21 | ||
22 | protected abstract void StoreAsset(AssetBase asset); | 22 | protected abstract void StoreAsset(AssetBase asset); |
23 | protected abstract void CommitAssets(); | 23 | protected abstract void CommitAssets(); |
24 | 24 | ||
25 | protected abstract void RunRequests(); | 25 | protected abstract void RunRequests(); |
26 | 26 | ||
27 | public void LoadDefaultAssets() | 27 | public void LoadDefaultAssets() |
28 | { | 28 | { |
29 | MainLog.Instance.Verbose("SQL ASSET SERVER", "Setting up asset database"); | 29 | MainLog.Instance.Verbose("SQL ASSET SERVER", "Setting up asset database"); |
30 | 30 | ||
31 | ForEachDefaultAsset(StoreAsset ); | 31 | ForEachDefaultAsset(StoreAsset ); |
32 | ForEachXmlAsset(StoreAsset ); | 32 | ForEachXmlAsset(StoreAsset ); |
33 | 33 | ||
34 | CommitAssets(); | 34 | CommitAssets(); |
35 | } | 35 | } |
36 | 36 | ||
37 | 37 | ||
38 | public AssetServerBase() | 38 | public AssetServerBase() |
39 | { | 39 | { |
40 | System.Console.WriteLine("Starting Db4o asset storage system"); | 40 | System.Console.WriteLine("Starting Db4o asset storage system"); |
41 | this._assetRequests = new BlockingQueue<ARequest>(); | 41 | this._assetRequests = new BlockingQueue<ARequest>(); |
42 | 42 | ||
43 | this._localAssetServerThread = new Thread( RunRequests ); | 43 | this._localAssetServerThread = new Thread( RunRequests ); |
44 | this._localAssetServerThread.IsBackground = true; | 44 | this._localAssetServerThread.IsBackground = true; |
45 | this._localAssetServerThread.Start(); | 45 | this._localAssetServerThread.Start(); |
46 | } | 46 | } |
47 | 47 | ||
48 | public void LoadAsset(AssetBase info, bool image, string filename) | 48 | public void LoadAsset(AssetBase info, bool image, string filename) |
49 | { | 49 | { |
50 | //should request Asset from storage manager | 50 | //should request Asset from storage manager |
51 | //but for now read from file | 51 | //but for now read from file |
52 | 52 | ||
53 | string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder; | 53 | string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder; |
54 | string fileName = Path.Combine(dataPath, filename); | 54 | string fileName = Path.Combine(dataPath, filename); |
55 | FileInfo fInfo = new FileInfo(fileName); | 55 | FileInfo fInfo = new FileInfo(fileName); |
56 | long numBytes = fInfo.Length; | 56 | long numBytes = fInfo.Length; |
57 | FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); | 57 | FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); |
58 | byte[] idata = new byte[numBytes]; | 58 | byte[] idata = new byte[numBytes]; |
59 | BinaryReader br = new BinaryReader(fStream); | 59 | BinaryReader br = new BinaryReader(fStream); |
60 | idata = br.ReadBytes((int)numBytes); | 60 | idata = br.ReadBytes((int)numBytes); |
61 | br.Close(); | 61 | br.Close(); |
62 | fStream.Close(); | 62 | fStream.Close(); |
63 | info.Data = idata; | 63 | info.Data = idata; |
64 | //info.loaded=true; | 64 | //info.loaded=true; |
65 | } | 65 | } |
66 | 66 | ||
67 | public void SetReceiver(IAssetReceiver receiver) | 67 | public void SetReceiver(IAssetReceiver receiver) |
68 | { | 68 | { |
69 | this._receiver = receiver; | 69 | this._receiver = receiver; |
70 | } | 70 | } |
71 | 71 | ||
72 | public void FetchAsset(LLUUID assetID, bool isTexture) | 72 | public void FetchAsset(LLUUID assetID, bool isTexture) |
73 | { | 73 | { |
74 | ARequest req = new ARequest(); | 74 | ARequest req = new ARequest(); |
75 | req.AssetID = assetID; | 75 | req.AssetID = assetID; |
76 | req.IsTexture = isTexture; | 76 | req.IsTexture = isTexture; |
77 | this._assetRequests.Enqueue(req); | 77 | this._assetRequests.Enqueue(req); |
78 | } | 78 | } |
79 | 79 | ||
80 | public void UpdateAsset(AssetBase asset) | 80 | public void UpdateAsset(AssetBase asset) |
81 | { | 81 | { |
82 | lock (syncLock) | 82 | lock (syncLock) |
83 | { | 83 | { |
84 | m_assetProviderPlugin.UpdateAsset(asset); | 84 | m_assetProviderPlugin.UpdateAsset(asset); |
85 | m_assetProviderPlugin.CommitAssets(); | 85 | m_assetProviderPlugin.CommitAssets(); |
86 | } | 86 | } |
87 | } | 87 | } |
88 | 88 | ||
89 | public void StoreAndCommitAsset(AssetBase asset) | 89 | public void StoreAndCommitAsset(AssetBase asset) |
90 | { | 90 | { |
91 | lock (syncLock) | 91 | lock (syncLock) |
92 | { | 92 | { |
93 | StoreAsset(asset); | 93 | StoreAsset(asset); |
94 | CommitAssets(); | 94 | CommitAssets(); |
95 | } | 95 | } |
96 | } | 96 | } |
97 | 97 | ||
98 | public virtual void Close() | 98 | public virtual void Close() |
99 | { | 99 | { |
100 | _localAssetServerThread.Abort( ); | 100 | _localAssetServerThread.Abort( ); |
101 | } | 101 | } |
102 | 102 | ||
103 | public void SetServerInfo(string ServerUrl, string ServerKey) | 103 | public void SetServerInfo(string ServerUrl, string ServerKey) |
104 | { | 104 | { |
105 | 105 | ||
106 | } | 106 | } |
107 | 107 | ||
108 | public virtual List<AssetBase> GetDefaultAssets() | 108 | public virtual List<AssetBase> GetDefaultAssets() |
109 | { | 109 | { |
110 | List<AssetBase> assets = new List<AssetBase>(); | 110 | List<AssetBase> assets = new List<AssetBase>(); |
111 | 111 | ||
112 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000001", "Bricks", "bricks.jp2")); | 112 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000001", "Bricks", "bricks.jp2")); |
113 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000002", "Plywood", "plywood.jp2")); | 113 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000002", "Plywood", "plywood.jp2")); |
114 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000003", "Rocks", "rocks.jp2")); | 114 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000003", "Rocks", "rocks.jp2")); |
115 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000004", "Granite", "granite.jp2")); | 115 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000004", "Granite", "granite.jp2")); |
116 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000005", "Hardwood", "hardwood.jp2")); | 116 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000005", "Hardwood", "hardwood.jp2")); |
117 | assets.Add(CreateImageAsset("00000000-0000-0000-5005-000000000005", "Prim Base Texture", "plywood.jp2")); | 117 | assets.Add(CreateImageAsset("00000000-0000-0000-5005-000000000005", "Prim Base Texture", "plywood.jp2")); |
118 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000006", "Map Base Texture", "map_base.jp2")); | 118 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000006", "Map Base Texture", "map_base.jp2")); |
119 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000007", "Map Texture", "map1.jp2")); | 119 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000007", "Map Texture", "map1.jp2")); |
120 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000010", "Female Body Texture", "femalebody.jp2")); | 120 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000010", "Female Body Texture", "femalebody.jp2")); |
121 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000011", "Female Bottom Texture", "femalebottom.jp2")); | 121 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000011", "Female Bottom Texture", "femalebottom.jp2")); |
122 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000012", "Female Face Texture", "femaleface.jp2")); | 122 | assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000012", "Female Face Texture", "femaleface.jp2")); |
123 | 123 | ||
124 | assets.Add(CreateAsset("77c41e39-38f9-f75a-024e-585989bbabbb", "Skin", "base_skin.dat", false)); | 124 | assets.Add(CreateAsset("77c41e39-38f9-f75a-024e-585989bbabbb", "Skin", "base_skin.dat", false)); |
125 | assets.Add(CreateAsset("66c41e39-38f9-f75a-024e-585989bfab73", "Shape", "base_shape.dat", false)); | 125 | assets.Add(CreateAsset("66c41e39-38f9-f75a-024e-585989bfab73", "Shape", "base_shape.dat", false)); |
126 | assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111110", "Shirt", "newshirt.dat", false)); | 126 | assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111110", "Shirt", "newshirt.dat", false)); |
127 | assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111120", "Shirt", "newpants.dat", false)); | 127 | assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111120", "Shirt", "newpants.dat", false)); |
128 | 128 | ||
129 | return assets; | 129 | return assets; |
130 | } | 130 | } |
131 | 131 | ||
132 | public AssetBase CreateImageAsset(string assetIdStr, string name, string filename) | 132 | public AssetBase CreateImageAsset(string assetIdStr, string name, string filename) |
133 | { | 133 | { |
134 | return CreateAsset(assetIdStr, name, filename, true); | 134 | return CreateAsset(assetIdStr, name, filename, true); |
135 | } | 135 | } |
136 | 136 | ||
137 | public void ForEachDefaultAsset(Action<AssetBase> action) | 137 | public void ForEachDefaultAsset(Action<AssetBase> action) |
138 | { | 138 | { |
139 | List<AssetBase> assets = GetDefaultAssets(); | 139 | List<AssetBase> assets = GetDefaultAssets(); |
140 | assets.ForEach(action); | 140 | assets.ForEach(action); |
141 | } | 141 | } |
142 | 142 | ||
143 | public AssetBase CreateAsset(string assetIdStr, string name, string filename, bool isImage) | 143 | public AssetBase CreateAsset(string assetIdStr, string name, string filename, bool isImage) |
144 | { | 144 | { |
145 | AssetBase asset = new AssetBase( | 145 | AssetBase asset = new AssetBase( |
146 | new LLUUID(assetIdStr), | 146 | new LLUUID(assetIdStr), |
147 | name | 147 | name |
148 | ); | 148 | ); |
149 | 149 | ||
150 | if (!String.IsNullOrEmpty(filename)) | 150 | if (!String.IsNullOrEmpty(filename)) |
151 | { | 151 | { |
152 | MainLog.Instance.Verbose("ASSETS", "Loading: [{0}][{1}]", name, filename ); | 152 | MainLog.Instance.Verbose("ASSETS", "Loading: [{0}][{1}]", name, filename ); |
153 | 153 | ||
154 | LoadAsset(asset, isImage, filename); | 154 | LoadAsset(asset, isImage, filename); |
155 | } | 155 | } |
156 | else | 156 | else |
157 | { | 157 | { |
158 | MainLog.Instance.Verbose("ASSETS", "Instantiated: [{0}]", name ); | 158 | MainLog.Instance.Verbose("ASSETS", "Instantiated: [{0}]", name ); |
159 | } | 159 | } |
160 | 160 | ||
161 | return asset; | 161 | return asset; |
162 | } | 162 | } |
163 | 163 | ||
164 | public void ForEachXmlAsset(Action<AssetBase> action) | 164 | public void ForEachXmlAsset(Action<AssetBase> action) |
165 | { | 165 | { |
166 | string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); | 166 | string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); |
167 | if (File.Exists(filePath)) | 167 | if (File.Exists(filePath)) |
168 | { | 168 | { |
169 | XmlConfigSource source = new XmlConfigSource(filePath); | 169 | XmlConfigSource source = new XmlConfigSource(filePath); |
170 | 170 | ||
171 | for (int i = 0; i < source.Configs.Count; i++) | 171 | for (int i = 0; i < source.Configs.Count; i++) |
172 | { | 172 | { |
173 | string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()); | 173 | string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()); |
174 | string name = source.Configs[i].GetString("name", ""); | 174 | string name = source.Configs[i].GetString("name", ""); |
175 | sbyte type = (sbyte)source.Configs[i].GetInt("assetType", 0); | 175 | sbyte type = (sbyte)source.Configs[i].GetInt("assetType", 0); |
176 | sbyte invType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); | 176 | sbyte invType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); |
177 | string fileName = source.Configs[i].GetString("fileName", ""); | 177 | string fileName = source.Configs[i].GetString("fileName", ""); |
178 | 178 | ||
179 | AssetBase newAsset = CreateAsset(assetIdStr, name, fileName, false); | 179 | AssetBase newAsset = CreateAsset(assetIdStr, name, fileName, false); |
180 | 180 | ||
181 | newAsset.Type = type; | 181 | newAsset.Type = type; |
182 | newAsset.InvType = invType; | 182 | newAsset.InvType = invType; |
183 | 183 | ||
184 | } | 184 | } |
185 | } | 185 | } |
186 | } | 186 | } |
187 | } | 187 | } |
188 | } \ No newline at end of file | 188 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 379d609..69f83d2 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs | |||
@@ -1,125 +1,125 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using System.Threading; | 30 | using System.Threading; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using libsecondlife; | 32 | using libsecondlife; |
33 | using Nini.Config; | 33 | using Nini.Config; |
34 | using OpenSim.Framework.Console; | 34 | using OpenSim.Framework.Console; |
35 | using OpenSim.Framework.Interfaces; | 35 | using OpenSim.Framework.Interfaces; |
36 | using OpenSim.Framework.Types; | 36 | using OpenSim.Framework.Types; |
37 | using OpenSim.Framework.Utilities; | 37 | using OpenSim.Framework.Utilities; |
38 | 38 | ||
39 | namespace OpenSim.Framework.Communications.Cache | 39 | namespace OpenSim.Framework.Communications.Cache |
40 | { | 40 | { |
41 | public class SQLAssetServer : AssetServerBase | 41 | public class SQLAssetServer : AssetServerBase |
42 | { | 42 | { |
43 | public SQLAssetServer(string pluginName) | 43 | public SQLAssetServer(string pluginName) |
44 | { | 44 | { |
45 | _assetRequests = new BlockingQueue<ARequest>(); | 45 | _assetRequests = new BlockingQueue<ARequest>(); |
46 | AddPlugin(pluginName); | 46 | AddPlugin(pluginName); |
47 | } | 47 | } |
48 | 48 | ||
49 | public SQLAssetServer(IAssetProvider assetProvider) | 49 | public SQLAssetServer(IAssetProvider assetProvider) |
50 | { | 50 | { |
51 | m_assetProviderPlugin = assetProvider; | 51 | m_assetProviderPlugin = assetProvider; |
52 | } | 52 | } |
53 | 53 | ||
54 | public void AddPlugin(string FileName) | 54 | public void AddPlugin(string FileName) |
55 | { | 55 | { |
56 | MainLog.Instance.Verbose("SQLAssetServer", "AssetStorage: Attempting to load " + FileName); | 56 | MainLog.Instance.Verbose("SQLAssetServer", "AssetStorage: Attempting to load " + FileName); |
57 | Assembly pluginAssembly = Assembly.LoadFrom(FileName); | 57 | Assembly pluginAssembly = Assembly.LoadFrom(FileName); |
58 | 58 | ||
59 | foreach (Type pluginType in pluginAssembly.GetTypes()) | 59 | foreach (Type pluginType in pluginAssembly.GetTypes()) |
60 | { | 60 | { |
61 | if (!pluginType.IsAbstract) | 61 | if (!pluginType.IsAbstract) |
62 | { | 62 | { |
63 | Type typeInterface = pluginType.GetInterface("IAssetProvider", true); | 63 | Type typeInterface = pluginType.GetInterface("IAssetProvider", true); |
64 | 64 | ||
65 | if (typeInterface != null) | 65 | if (typeInterface != null) |
66 | { | 66 | { |
67 | IAssetProvider plug = (IAssetProvider)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | 67 | IAssetProvider plug = (IAssetProvider)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); |
68 | m_assetProviderPlugin = plug; | 68 | m_assetProviderPlugin = plug; |
69 | m_assetProviderPlugin.Initialise(); | 69 | m_assetProviderPlugin.Initialise(); |
70 | 70 | ||
71 | MainLog.Instance.Verbose("AssetStorage: Added " + m_assetProviderPlugin.Name + " " + m_assetProviderPlugin.Version); | 71 | MainLog.Instance.Verbose("AssetStorage: Added " + m_assetProviderPlugin.Name + " " + m_assetProviderPlugin.Version); |
72 | } | 72 | } |
73 | 73 | ||
74 | typeInterface = null; | 74 | typeInterface = null; |
75 | } | 75 | } |
76 | } | 76 | } |
77 | 77 | ||
78 | pluginAssembly = null; | 78 | pluginAssembly = null; |
79 | } | 79 | } |
80 | 80 | ||
81 | 81 | ||
82 | public override void Close() | 82 | public override void Close() |
83 | { | 83 | { |
84 | base.Close(); | 84 | base.Close(); |
85 | 85 | ||
86 | m_assetProviderPlugin.CommitAssets(); | 86 | m_assetProviderPlugin.CommitAssets(); |
87 | } | 87 | } |
88 | 88 | ||
89 | override protected void RunRequests() | 89 | override protected void RunRequests() |
90 | { | 90 | { |
91 | while (true) | 91 | while (true) |
92 | { | 92 | { |
93 | ARequest req = this._assetRequests.Dequeue(); | 93 | ARequest req = this._assetRequests.Dequeue(); |
94 | 94 | ||
95 | MainLog.Instance.Verbose("Requesting asset: " + req.AssetID); | 95 | MainLog.Instance.Verbose("Requesting asset: " + req.AssetID); |
96 | 96 | ||
97 | AssetBase asset = null; | 97 | AssetBase asset = null; |
98 | lock (syncLock) | 98 | lock (syncLock) |
99 | { | 99 | { |
100 | asset = m_assetProviderPlugin.FetchAsset(req.AssetID); | 100 | asset = m_assetProviderPlugin.FetchAsset(req.AssetID); |
101 | } | 101 | } |
102 | if (asset != null) | 102 | if (asset != null) |
103 | { | 103 | { |
104 | _receiver.AssetReceived(asset, req.IsTexture); | 104 | _receiver.AssetReceived(asset, req.IsTexture); |
105 | } | 105 | } |
106 | else | 106 | else |
107 | { | 107 | { |
108 | _receiver.AssetNotFound(req.AssetID); | 108 | _receiver.AssetNotFound(req.AssetID); |
109 | } | 109 | } |
110 | 110 | ||
111 | } | 111 | } |
112 | 112 | ||
113 | } | 113 | } |
114 | 114 | ||
115 | protected override void StoreAsset(AssetBase asset) | 115 | protected override void StoreAsset(AssetBase asset) |
116 | { | 116 | { |
117 | m_assetProviderPlugin.CreateAsset(asset); | 117 | m_assetProviderPlugin.CreateAsset(asset); |
118 | } | 118 | } |
119 | 119 | ||
120 | protected override void CommitAssets() | 120 | protected override void CommitAssets() |
121 | { | 121 | { |
122 | m_assetProviderPlugin.CommitAssets(); | 122 | m_assetProviderPlugin.CommitAssets(); |
123 | } | 123 | } |
124 | } | 124 | } |
125 | } \ No newline at end of file | 125 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 85af5db..674c746 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs | |||
@@ -1,315 +1,315 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Collections; | 30 | using System.Collections; |
31 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using System.Security.Cryptography; | 33 | using System.Security.Cryptography; |
34 | using libsecondlife; | 34 | using libsecondlife; |
35 | using Nwc.XmlRpc; | 35 | using Nwc.XmlRpc; |
36 | using OpenSim.Framework.Console; | 36 | using OpenSim.Framework.Console; |
37 | using OpenSim.Framework.Interfaces; | 37 | using OpenSim.Framework.Interfaces; |
38 | using OpenSim.Framework.Inventory; | 38 | using OpenSim.Framework.Inventory; |
39 | using OpenSim.Framework.Types; | 39 | using OpenSim.Framework.Types; |
40 | using OpenSim.Framework.Utilities; | 40 | using OpenSim.Framework.Utilities; |
41 | 41 | ||
42 | using OpenSim.Framework.Configuration; | 42 | using OpenSim.Framework.Configuration; |
43 | using InventoryFolder = OpenSim.Framework.Inventory.InventoryFolder; | 43 | using InventoryFolder = OpenSim.Framework.Inventory.InventoryFolder; |
44 | 44 | ||
45 | namespace OpenSim.Framework.UserManagement | 45 | namespace OpenSim.Framework.UserManagement |
46 | { | 46 | { |
47 | public class LoginService | 47 | public class LoginService |
48 | { | 48 | { |
49 | protected string m_welcomeMessage = "Welcome to OpenSim"; | 49 | protected string m_welcomeMessage = "Welcome to OpenSim"; |
50 | protected UserManagerBase m_userManager = null; | 50 | protected UserManagerBase m_userManager = null; |
51 | 51 | ||
52 | public LoginService(UserManagerBase userManager, string welcomeMess) | 52 | public LoginService(UserManagerBase userManager, string welcomeMess) |
53 | { | 53 | { |
54 | m_userManager = userManager; | 54 | m_userManager = userManager; |
55 | if (welcomeMess != "") | 55 | if (welcomeMess != "") |
56 | { | 56 | { |
57 | m_welcomeMessage = welcomeMess; | 57 | m_welcomeMessage = welcomeMess; |
58 | } | 58 | } |
59 | } | 59 | } |
60 | 60 | ||
61 | /// <summary> | 61 | /// <summary> |
62 | /// Main user login function | 62 | /// Main user login function |
63 | /// </summary> | 63 | /// </summary> |
64 | /// <param name="request">The XMLRPC request</param> | 64 | /// <param name="request">The XMLRPC request</param> |
65 | /// <returns>The response to send</returns> | 65 | /// <returns>The response to send</returns> |
66 | public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) | 66 | public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) |
67 | { | 67 | { |
68 | 68 | ||
69 | MainLog.Instance.Verbose("Attempting login now..."); | 69 | MainLog.Instance.Verbose("Attempting login now..."); |
70 | XmlRpcResponse response = new XmlRpcResponse(); | 70 | XmlRpcResponse response = new XmlRpcResponse(); |
71 | Hashtable requestData = (Hashtable)request.Params[0]; | 71 | Hashtable requestData = (Hashtable)request.Params[0]; |
72 | 72 | ||
73 | bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); | 73 | bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); |
74 | bool GoodLogin = false; | 74 | bool GoodLogin = false; |
75 | 75 | ||
76 | UserProfileData userProfile; | 76 | UserProfileData userProfile; |
77 | LoginResponse logResponse = new LoginResponse(); | 77 | LoginResponse logResponse = new LoginResponse(); |
78 | 78 | ||
79 | if (GoodXML) | 79 | if (GoodXML) |
80 | { | 80 | { |
81 | string firstname = (string)requestData["first"]; | 81 | string firstname = (string)requestData["first"]; |
82 | string lastname = (string)requestData["last"]; | 82 | string lastname = (string)requestData["last"]; |
83 | string passwd = (string)requestData["passwd"]; | 83 | string passwd = (string)requestData["passwd"]; |
84 | 84 | ||
85 | userProfile = GetTheUser(firstname, lastname); | 85 | userProfile = GetTheUser(firstname, lastname); |
86 | if (userProfile == null) | 86 | if (userProfile == null) |
87 | return logResponse.CreateLoginFailedResponse(); | 87 | return logResponse.CreateLoginFailedResponse(); |
88 | 88 | ||
89 | GoodLogin = AuthenticateUser(userProfile, passwd); | 89 | GoodLogin = AuthenticateUser(userProfile, passwd); |
90 | } | 90 | } |
91 | else | 91 | else |
92 | { | 92 | { |
93 | return logResponse.CreateGridErrorResponse(); | 93 | return logResponse.CreateGridErrorResponse(); |
94 | } | 94 | } |
95 | 95 | ||
96 | if (!GoodLogin) | 96 | if (!GoodLogin) |
97 | { | 97 | { |
98 | return logResponse.CreateLoginFailedResponse(); | 98 | return logResponse.CreateLoginFailedResponse(); |
99 | } | 99 | } |
100 | else | 100 | else |
101 | { | 101 | { |
102 | // If we already have a session... | 102 | // If we already have a session... |
103 | if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) | 103 | if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) |
104 | { | 104 | { |
105 | // Reject the login | 105 | // Reject the login |
106 | return logResponse.CreateAlreadyLoggedInResponse(); | 106 | return logResponse.CreateAlreadyLoggedInResponse(); |
107 | } | 107 | } |
108 | // Otherwise... | 108 | // Otherwise... |
109 | // Create a new agent session | 109 | // Create a new agent session |
110 | CreateAgent(userProfile, request); | 110 | CreateAgent(userProfile, request); |
111 | 111 | ||
112 | try | 112 | try |
113 | { | 113 | { |
114 | LLUUID agentID = userProfile.UUID; | 114 | LLUUID agentID = userProfile.UUID; |
115 | 115 | ||
116 | // Inventory Library Section | 116 | // Inventory Library Section |
117 | InventoryData inventData = this.CreateInventoryData(agentID); | 117 | InventoryData inventData = this.CreateInventoryData(agentID); |
118 | ArrayList AgentInventoryArray = inventData.InventoryArray; | 118 | ArrayList AgentInventoryArray = inventData.InventoryArray; |
119 | 119 | ||
120 | Hashtable InventoryRootHash = new Hashtable(); | 120 | Hashtable InventoryRootHash = new Hashtable(); |
121 | InventoryRootHash["folder_id"] = inventData.RootFolderID.ToStringHyphenated(); | 121 | InventoryRootHash["folder_id"] = inventData.RootFolderID.ToStringHyphenated(); |
122 | ArrayList InventoryRoot = new ArrayList(); | 122 | ArrayList InventoryRoot = new ArrayList(); |
123 | InventoryRoot.Add(InventoryRootHash); | 123 | InventoryRoot.Add(InventoryRootHash); |
124 | userProfile.rootInventoryFolderID = inventData.RootFolderID; | 124 | userProfile.rootInventoryFolderID = inventData.RootFolderID; |
125 | 125 | ||
126 | // Circuit Code | 126 | // Circuit Code |
127 | uint circode = (uint)(Util.RandomClass.Next()); | 127 | uint circode = (uint)(Util.RandomClass.Next()); |
128 | 128 | ||
129 | logResponse.Lastname = userProfile.surname; | 129 | logResponse.Lastname = userProfile.surname; |
130 | logResponse.Firstname = userProfile.username; | 130 | logResponse.Firstname = userProfile.username; |
131 | logResponse.AgentID = agentID.ToStringHyphenated(); | 131 | logResponse.AgentID = agentID.ToStringHyphenated(); |
132 | logResponse.SessionID = userProfile.currentAgent.sessionID.ToStringHyphenated(); | 132 | logResponse.SessionID = userProfile.currentAgent.sessionID.ToStringHyphenated(); |
133 | logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated(); | 133 | logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated(); |
134 | logResponse.InventoryRoot = InventoryRoot; | 134 | logResponse.InventoryRoot = InventoryRoot; |
135 | logResponse.InventorySkeleton = AgentInventoryArray; | 135 | logResponse.InventorySkeleton = AgentInventoryArray; |
136 | logResponse.InventoryLibrary = this.GetInventoryLibrary(); | 136 | logResponse.InventoryLibrary = this.GetInventoryLibrary(); |
137 | logResponse.InventoryLibraryOwner = this.GetLibraryOwner(); | 137 | logResponse.InventoryLibraryOwner = this.GetLibraryOwner(); |
138 | logResponse.CircuitCode = (Int32)circode; | 138 | logResponse.CircuitCode = (Int32)circode; |
139 | //logResponse.RegionX = 0; //overwritten | 139 | //logResponse.RegionX = 0; //overwritten |
140 | //logResponse.RegionY = 0; //overwritten | 140 | //logResponse.RegionY = 0; //overwritten |
141 | logResponse.Home = "!!null temporary value {home}!!"; // Overwritten | 141 | logResponse.Home = "!!null temporary value {home}!!"; // Overwritten |
142 | //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; | 142 | //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; |
143 | //logResponse.SimAddress = "127.0.0.1"; //overwritten | 143 | //logResponse.SimAddress = "127.0.0.1"; //overwritten |
144 | //logResponse.SimPort = 0; //overwritten | 144 | //logResponse.SimPort = 0; //overwritten |
145 | logResponse.Message = this.GetMessage(); | 145 | logResponse.Message = this.GetMessage(); |
146 | 146 | ||
147 | try | 147 | try |
148 | { | 148 | { |
149 | this.CustomiseResponse(logResponse, userProfile); | 149 | this.CustomiseResponse(logResponse, userProfile); |
150 | } | 150 | } |
151 | catch (Exception e) | 151 | catch (Exception e) |
152 | { | 152 | { |
153 | MainLog.Instance.Verbose(e.ToString()); | 153 | MainLog.Instance.Verbose(e.ToString()); |
154 | return logResponse.CreateDeadRegionResponse(); | 154 | return logResponse.CreateDeadRegionResponse(); |
155 | //return logResponse.ToXmlRpcResponse(); | 155 | //return logResponse.ToXmlRpcResponse(); |
156 | } | 156 | } |
157 | CommitAgent(ref userProfile); | 157 | CommitAgent(ref userProfile); |
158 | return logResponse.ToXmlRpcResponse(); | 158 | return logResponse.ToXmlRpcResponse(); |
159 | 159 | ||
160 | } | 160 | } |
161 | 161 | ||
162 | catch (Exception E) | 162 | catch (Exception E) |
163 | { | 163 | { |
164 | MainLog.Instance.Verbose(E.ToString()); | 164 | MainLog.Instance.Verbose(E.ToString()); |
165 | } | 165 | } |
166 | //} | 166 | //} |
167 | } | 167 | } |
168 | return response; | 168 | return response; |
169 | 169 | ||
170 | } | 170 | } |
171 | 171 | ||
172 | /// <summary> | 172 | /// <summary> |
173 | /// Customises the login response and fills in missing values. | 173 | /// Customises the login response and fills in missing values. |
174 | /// </summary> | 174 | /// </summary> |
175 | /// <param name="response">The existing response</param> | 175 | /// <param name="response">The existing response</param> |
176 | /// <param name="theUser">The user profile</param> | 176 | /// <param name="theUser">The user profile</param> |
177 | public virtual void CustomiseResponse(LoginResponse response, UserProfileData theUser) | 177 | public virtual void CustomiseResponse(LoginResponse response, UserProfileData theUser) |
178 | { | 178 | { |
179 | } | 179 | } |
180 | 180 | ||
181 | /// <summary> | 181 | /// <summary> |
182 | /// Saves a target agent to the database | 182 | /// Saves a target agent to the database |
183 | /// </summary> | 183 | /// </summary> |
184 | /// <param name="profile">The users profile</param> | 184 | /// <param name="profile">The users profile</param> |
185 | /// <returns>Successful?</returns> | 185 | /// <returns>Successful?</returns> |
186 | public bool CommitAgent(ref UserProfileData profile) | 186 | public bool CommitAgent(ref UserProfileData profile) |
187 | { | 187 | { |
188 | // Saves the agent to database | 188 | // Saves the agent to database |
189 | return true; | 189 | return true; |
190 | } | 190 | } |
191 | 191 | ||
192 | 192 | ||
193 | /// <summary> | 193 | /// <summary> |
194 | /// Checks a user against it's password hash | 194 | /// Checks a user against it's password hash |
195 | /// </summary> | 195 | /// </summary> |
196 | /// <param name="profile">The users profile</param> | 196 | /// <param name="profile">The users profile</param> |
197 | /// <param name="password">The supplied password</param> | 197 | /// <param name="password">The supplied password</param> |
198 | /// <returns>Authenticated?</returns> | 198 | /// <returns>Authenticated?</returns> |
199 | public virtual bool AuthenticateUser(UserProfileData profile, string password) | 199 | public virtual bool AuthenticateUser(UserProfileData profile, string password) |
200 | { | 200 | { |
201 | 201 | ||
202 | MainLog.Instance.Verbose( | 202 | MainLog.Instance.Verbose( |
203 | "Authenticating " + profile.username + " " + profile.surname); | 203 | "Authenticating " + profile.username + " " + profile.surname); |
204 | 204 | ||
205 | password = password.Remove(0, 3); //remove $1$ | 205 | password = password.Remove(0, 3); //remove $1$ |
206 | 206 | ||
207 | string s = Util.Md5Hash(password + ":" + profile.passwordSalt); | 207 | string s = Util.Md5Hash(password + ":" + profile.passwordSalt); |
208 | 208 | ||
209 | return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); | 209 | return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); |
210 | } | 210 | } |
211 | 211 | ||
212 | /// <summary> | 212 | /// <summary> |
213 | /// | 213 | /// |
214 | /// </summary> | 214 | /// </summary> |
215 | /// <param name="profile"></param> | 215 | /// <param name="profile"></param> |
216 | /// <param name="request"></param> | 216 | /// <param name="request"></param> |
217 | public void CreateAgent(UserProfileData profile, XmlRpcRequest request) | 217 | public void CreateAgent(UserProfileData profile, XmlRpcRequest request) |
218 | { | 218 | { |
219 | this.m_userManager.CreateAgent(profile, request); | 219 | this.m_userManager.CreateAgent(profile, request); |
220 | } | 220 | } |
221 | 221 | ||
222 | /// <summary> | 222 | /// <summary> |
223 | /// | 223 | /// |
224 | /// </summary> | 224 | /// </summary> |
225 | /// <param name="firstname"></param> | 225 | /// <param name="firstname"></param> |
226 | /// <param name="lastname"></param> | 226 | /// <param name="lastname"></param> |
227 | /// <returns></returns> | 227 | /// <returns></returns> |
228 | public virtual UserProfileData GetTheUser(string firstname, string lastname) | 228 | public virtual UserProfileData GetTheUser(string firstname, string lastname) |
229 | { | 229 | { |
230 | return this.m_userManager.GetUserProfile(firstname, lastname); | 230 | return this.m_userManager.GetUserProfile(firstname, lastname); |
231 | } | 231 | } |
232 | 232 | ||
233 | /// <summary> | 233 | /// <summary> |
234 | /// | 234 | /// |
235 | /// </summary> | 235 | /// </summary> |
236 | /// <returns></returns> | 236 | /// <returns></returns> |
237 | public virtual string GetMessage() | 237 | public virtual string GetMessage() |
238 | { | 238 | { |
239 | return m_welcomeMessage; | 239 | return m_welcomeMessage; |
240 | } | 240 | } |
241 | 241 | ||
242 | /// <summary> | 242 | /// <summary> |
243 | /// | 243 | /// |
244 | /// </summary> | 244 | /// </summary> |
245 | /// <returns></returns> | 245 | /// <returns></returns> |
246 | protected virtual ArrayList GetInventoryLibrary() | 246 | protected virtual ArrayList GetInventoryLibrary() |
247 | { | 247 | { |
248 | //return new ArrayList(); | 248 | //return new ArrayList(); |
249 | Hashtable TempHash = new Hashtable(); | 249 | Hashtable TempHash = new Hashtable(); |
250 | TempHash["name"] = "OpenSim Library"; | 250 | TempHash["name"] = "OpenSim Library"; |
251 | TempHash["parent_id"] = LLUUID.Zero.ToStringHyphenated(); | 251 | TempHash["parent_id"] = LLUUID.Zero.ToStringHyphenated(); |
252 | TempHash["version"] = 1; | 252 | TempHash["version"] = 1; |
253 | TempHash["type_default"] = -1; | 253 | TempHash["type_default"] = -1; |
254 | TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; | 254 | TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; |
255 | ArrayList temp = new ArrayList(); | 255 | ArrayList temp = new ArrayList(); |
256 | temp.Add(TempHash); | 256 | temp.Add(TempHash); |
257 | 257 | ||
258 | TempHash = new Hashtable(); | 258 | TempHash = new Hashtable(); |
259 | TempHash["name"] = "Texture Library"; | 259 | TempHash["name"] = "Texture Library"; |
260 | TempHash["parent_id"] = "00000112-000f-0000-0000-000100bba000"; | 260 | TempHash["parent_id"] = "00000112-000f-0000-0000-000100bba000"; |
261 | TempHash["version"] = 1; | 261 | TempHash["version"] = 1; |
262 | TempHash["type_default"] = -1; | 262 | TempHash["type_default"] = -1; |
263 | TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001"; | 263 | TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001"; |
264 | temp.Add(TempHash); | 264 | temp.Add(TempHash); |
265 | return temp; | 265 | return temp; |
266 | } | 266 | } |
267 | 267 | ||
268 | /// <summary> | 268 | /// <summary> |
269 | /// | 269 | /// |
270 | /// </summary> | 270 | /// </summary> |
271 | /// <returns></returns> | 271 | /// <returns></returns> |
272 | protected virtual ArrayList GetLibraryOwner() | 272 | protected virtual ArrayList GetLibraryOwner() |
273 | { | 273 | { |
274 | //for now create random inventory library owner | 274 | //for now create random inventory library owner |
275 | Hashtable TempHash = new Hashtable(); | 275 | Hashtable TempHash = new Hashtable(); |
276 | TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; | 276 | TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; |
277 | ArrayList inventoryLibOwner = new ArrayList(); | 277 | ArrayList inventoryLibOwner = new ArrayList(); |
278 | inventoryLibOwner.Add(TempHash); | 278 | inventoryLibOwner.Add(TempHash); |
279 | return inventoryLibOwner; | 279 | return inventoryLibOwner; |
280 | } | 280 | } |
281 | 281 | ||
282 | protected virtual InventoryData CreateInventoryData(LLUUID userID) | 282 | protected virtual InventoryData CreateInventoryData(LLUUID userID) |
283 | { | 283 | { |
284 | AgentInventory userInventory = new AgentInventory(); | 284 | AgentInventory userInventory = new AgentInventory(); |
285 | userInventory.CreateRootFolder(userID, false); | 285 | userInventory.CreateRootFolder(userID, false); |
286 | 286 | ||
287 | ArrayList AgentInventoryArray = new ArrayList(); | 287 | ArrayList AgentInventoryArray = new ArrayList(); |
288 | Hashtable TempHash; | 288 | Hashtable TempHash; |
289 | foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values) | 289 | foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values) |
290 | { | 290 | { |
291 | TempHash = new Hashtable(); | 291 | TempHash = new Hashtable(); |
292 | TempHash["name"] = InvFolder.FolderName; | 292 | TempHash["name"] = InvFolder.FolderName; |
293 | TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); | 293 | TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); |
294 | TempHash["version"] = (Int32)InvFolder.Version; | 294 | TempHash["version"] = (Int32)InvFolder.Version; |
295 | TempHash["type_default"] = (Int32)InvFolder.DefaultType; | 295 | TempHash["type_default"] = (Int32)InvFolder.DefaultType; |
296 | TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); | 296 | TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); |
297 | AgentInventoryArray.Add(TempHash); | 297 | AgentInventoryArray.Add(TempHash); |
298 | } | 298 | } |
299 | 299 | ||
300 | return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID); | 300 | return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID); |
301 | } | 301 | } |
302 | 302 | ||
303 | public class InventoryData | 303 | public class InventoryData |
304 | { | 304 | { |
305 | public ArrayList InventoryArray = null; | 305 | public ArrayList InventoryArray = null; |
306 | public LLUUID RootFolderID = LLUUID.Zero; | 306 | public LLUUID RootFolderID = LLUUID.Zero; |
307 | 307 | ||
308 | public InventoryData(ArrayList invList, LLUUID rootID) | 308 | public InventoryData(ArrayList invList, LLUUID rootID) |
309 | { | 309 | { |
310 | InventoryArray = invList; | 310 | InventoryArray = invList; |
311 | RootFolderID = rootID; | 311 | RootFolderID = rootID; |
312 | } | 312 | } |
313 | } | 313 | } |
314 | } | 314 | } |
315 | } | 315 | } |