diff options
author | StrawberryFride | 2010-02-24 16:42:39 +0000 |
---|---|---|
committer | Melanie | 2010-02-24 15:50:44 +0000 |
commit | 2fa5694ec9857f208b6fe4d0890fd2ab8ac1b8bf (patch) | |
tree | 672ec2bb3e64b8f930faa9a87801ba9042e2d4f7 /OpenSim/Data/MSSQL/MSSQLXInventoryData.cs | |
parent | Fixed typo that was affecting the BasicInventoryAccessModule (diff) | |
download | opensim-SC_OLD-2fa5694ec9857f208b6fe4d0890fd2ab8ac1b8bf.zip opensim-SC_OLD-2fa5694ec9857f208b6fe4d0890fd2ab8ac1b8bf.tar.gz opensim-SC_OLD-2fa5694ec9857f208b6fe4d0890fd2ab8ac1b8bf.tar.bz2 opensim-SC_OLD-2fa5694ec9857f208b6fe4d0890fd2ab8ac1b8bf.tar.xz |
MSSQL Additions for Presence Refactor branch. Most functionality tested and works, some outstanding issues around login location and border crossings on y axis.
Signed-off-by: Melanie <melanie@t-data.com>
Diffstat (limited to 'OpenSim/Data/MSSQL/MSSQLXInventoryData.cs')
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLXInventoryData.cs | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs new file mode 100644 index 0000000..739eb55 --- /dev/null +++ b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs | |||
@@ -0,0 +1,166 @@ | |||
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 OpenSimulator 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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Data; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using System.Data.SqlClient; | ||
35 | using System.Reflection; | ||
36 | using System.Text; | ||
37 | using log4net; | ||
38 | |||
39 | namespace OpenSim.Data.MSSQL | ||
40 | { | ||
41 | public class MSSQLXInventoryData : IXInventoryData | ||
42 | { | ||
43 | private static readonly ILog m_log = LogManager.GetLogger( | ||
44 | MethodBase.GetCurrentMethod().DeclaringType); | ||
45 | |||
46 | private MSSQLGenericTableHandler<XInventoryFolder> m_Folders; | ||
47 | private MSSQLItemHandler m_Items; | ||
48 | |||
49 | public MSSQLXInventoryData(string conn, string realm) | ||
50 | { | ||
51 | m_Folders = new MSSQLGenericTableHandler<XInventoryFolder>( | ||
52 | conn, "inventoryfolders", "InventoryStore"); | ||
53 | m_Items = new MSSQLItemHandler( | ||
54 | conn, "inventoryitems", String.Empty); | ||
55 | } | ||
56 | |||
57 | public XInventoryFolder[] GetFolders(string[] fields, string[] vals) | ||
58 | { | ||
59 | return m_Folders.Get(fields, vals); | ||
60 | } | ||
61 | |||
62 | public XInventoryItem[] GetItems(string[] fields, string[] vals) | ||
63 | { | ||
64 | return m_Items.Get(fields, vals); | ||
65 | } | ||
66 | |||
67 | public bool StoreFolder(XInventoryFolder folder) | ||
68 | { | ||
69 | return m_Folders.Store(folder); | ||
70 | } | ||
71 | |||
72 | public bool StoreItem(XInventoryItem item) | ||
73 | { | ||
74 | return m_Items.Store(item); | ||
75 | } | ||
76 | |||
77 | public bool DeleteFolders(string field, string val) | ||
78 | { | ||
79 | return m_Folders.Delete(field, val); | ||
80 | } | ||
81 | |||
82 | public bool DeleteItems(string field, string val) | ||
83 | { | ||
84 | return m_Items.Delete(field, val); | ||
85 | } | ||
86 | |||
87 | public bool MoveItem(string id, string newParent) | ||
88 | { | ||
89 | return m_Items.MoveItem(id, newParent); | ||
90 | } | ||
91 | |||
92 | public XInventoryItem[] GetActiveGestures(UUID principalID) | ||
93 | { | ||
94 | return m_Items.GetActiveGestures(principalID); | ||
95 | } | ||
96 | |||
97 | public int GetAssetPermissions(UUID principalID, UUID assetID) | ||
98 | { | ||
99 | return m_Items.GetAssetPermissions(principalID, assetID); | ||
100 | } | ||
101 | } | ||
102 | |||
103 | public class MSSQLItemHandler : MSSQLGenericTableHandler<XInventoryItem> | ||
104 | { | ||
105 | public MSSQLItemHandler(string c, string t, string m) : | ||
106 | base(c, t, m) | ||
107 | { | ||
108 | } | ||
109 | |||
110 | public bool MoveItem(string id, string newParent) | ||
111 | { | ||
112 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | ||
113 | using (SqlCommand cmd = new SqlCommand()) | ||
114 | { | ||
115 | |||
116 | cmd.CommandText = String.Format("update {0} set parentFolderID = @ParentFolderID where inventoryID = @InventoryID", m_Realm); | ||
117 | cmd.Parameters.Add(m_database.CreateParameter("@ParentFolderID", newParent)); | ||
118 | cmd.Parameters.Add(m_database.CreateParameter("@InventoryID", id)); | ||
119 | cmd.Connection = conn; | ||
120 | conn.Open(); | ||
121 | return cmd.ExecuteNonQuery() == 0 ? false : true; | ||
122 | } | ||
123 | } | ||
124 | |||
125 | public XInventoryItem[] GetActiveGestures(UUID principalID) | ||
126 | { | ||
127 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | ||
128 | using (SqlCommand cmd = new SqlCommand()) | ||
129 | { | ||
130 | cmd.CommandText = String.Format("select * from inventoryitems where avatarId = @uuid and assetType = @type and flags = 1", m_Realm); | ||
131 | |||
132 | cmd.Parameters.Add(m_database.CreateParameter("@uuid", principalID.ToString())); | ||
133 | cmd.Parameters.Add(m_database.CreateParameter("@type", (int)AssetType.Gesture)); | ||
134 | cmd.Connection = conn; | ||
135 | conn.Open(); | ||
136 | return DoQuery(cmd); | ||
137 | } | ||
138 | } | ||
139 | |||
140 | public int GetAssetPermissions(UUID principalID, UUID assetID) | ||
141 | { | ||
142 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | ||
143 | using (SqlCommand cmd = new SqlCommand()) | ||
144 | { | ||
145 | cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = @PrincipalID and assetID = @AssetID group by assetID", m_Realm); | ||
146 | cmd.Parameters.Add(m_database.CreateParameter("@PrincipalID", principalID.ToString())); | ||
147 | cmd.Parameters.Add(m_database.CreateParameter("@AssetID", assetID.ToString())); | ||
148 | cmd.Connection = conn; | ||
149 | conn.Open(); | ||
150 | using (SqlDataReader reader = cmd.ExecuteReader()) | ||
151 | { | ||
152 | |||
153 | int perms = 0; | ||
154 | |||
155 | if (reader.Read()) | ||
156 | { | ||
157 | perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]); | ||
158 | } | ||
159 | |||
160 | return perms; | ||
161 | } | ||
162 | |||
163 | } | ||
164 | } | ||
165 | } | ||
166 | } | ||