aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache
diff options
context:
space:
mode:
authorSean Dague2007-10-19 20:28:18 +0000
committerSean Dague2007-10-19 20:28:18 +0000
commitd4bb430f78d9a70137957c8fe42de8fa620597ef (patch)
tree49612ce0a47acaedfa826d33edbe200c4c2d8b3c /OpenSim/Framework/Communications/Cache
parentchanges to pass nini config object to the modules that get (diff)
downloadopensim-SC_OLD-d4bb430f78d9a70137957c8fe42de8fa620597ef.zip
opensim-SC_OLD-d4bb430f78d9a70137957c8fe42de8fa620597ef.tar.gz
opensim-SC_OLD-d4bb430f78d9a70137957c8fe42de8fa620597ef.tar.bz2
opensim-SC_OLD-d4bb430f78d9a70137957c8fe42de8fa620597ef.tar.xz
get rid of all the ^M line endings
Diffstat (limited to 'OpenSim/Framework/Communications/Cache')
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetServer.cs312
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetServerBase.cs374
-rw-r--r--OpenSim/Framework/Communications/Cache/SQLAssetServer.cs248
3 files changed, 467 insertions, 467 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*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.Threading; 31using System.Threading;
32using Db4objects.Db4o; 32using Db4objects.Db4o;
33using Db4objects.Db4o.Query; 33using Db4objects.Db4o.Query;
34using libsecondlife; 34using libsecondlife;
35using Nini.Config; 35using Nini.Config;
36using OpenSim.Framework.Communications.Cache; 36using OpenSim.Framework.Communications.Cache;
37using OpenSim.Framework.Console; 37using OpenSim.Framework.Console;
38using OpenSim.Framework.Interfaces; 38using OpenSim.Framework.Interfaces;
39using OpenSim.Framework.Types; 39using OpenSim.Framework.Types;
40using OpenSim.Framework.Utilities; 40using OpenSim.Framework.Utilities;
41 41
42namespace OpenSim.Framework.Communications.Cache 42namespace 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 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.IO; 3using System.IO;
4using System.Threading; 4using System.Threading;
5using libsecondlife; 5using libsecondlife;
6using Nini.Config; 6using Nini.Config;
7using OpenSim.Framework.Console; 7using OpenSim.Framework.Console;
8using OpenSim.Framework.Interfaces; 8using OpenSim.Framework.Interfaces;
9using OpenSim.Framework.Types; 9using OpenSim.Framework.Types;
10using OpenSim.Framework.Utilities; 10using OpenSim.Framework.Utilities;
11 11
12namespace OpenSim.Framework.Communications.Cache 12namespace 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*/
28using System; 28using System;
29using System.IO; 29using System.IO;
30using System.Threading; 30using System.Threading;
31using System.Reflection; 31using System.Reflection;
32using libsecondlife; 32using libsecondlife;
33using Nini.Config; 33using Nini.Config;
34using OpenSim.Framework.Console; 34using OpenSim.Framework.Console;
35using OpenSim.Framework.Interfaces; 35using OpenSim.Framework.Interfaces;
36using OpenSim.Framework.Types; 36using OpenSim.Framework.Types;
37using OpenSim.Framework.Utilities; 37using OpenSim.Framework.Utilities;
38 38
39namespace OpenSim.Framework.Communications.Cache 39namespace 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