add some missing default group owner powers on xmlrpc groups module

plus more dotnet6 code style changes
This commit is contained in:
UbitUmarov
2022-10-28 20:06:45 +01:00
parent 496deb92d4
commit aa572df663
12 changed files with 806 additions and 961 deletions

View File

@@ -77,10 +77,10 @@ namespace OpenSim.Capabilities.Handlers
httpRequest.InputStream.Dispose();
OSDMap map = (OSDMap)tmp;
if(map.TryGetValue("folders", out tmp) && tmp is OSDArray)
foldersrequested = tmp as OSDArray;
if(map.TryGetValue("folders", out tmp) && tmp is OSDArray frtmp)
foldersrequested = frtmp;
if (foldersrequested == null || foldersrequested.Count == 0)
if (foldersrequested is null || foldersrequested.Count == 0)
{
httpResponse.RawBuffer = EmptyResponse;
return;
@@ -125,7 +125,7 @@ namespace OpenSim.Capabilities.Handlers
return;
}
if (folders == null || folders.Count == 0)
if (folders is null || folders.Count == 0)
{
if(bad_folders.Count == 0)
{
@@ -235,7 +235,6 @@ namespace OpenSim.Capabilities.Handlers
invcollSet[i] = null;
}
LLSDxmlEncode2.AddEndArrayAndMap(lastresponse);
thiscoll = null;
}
else
{
@@ -261,7 +260,7 @@ namespace OpenSim.Capabilities.Handlers
int limit = 9;
foreach (UUID bad in bad_folders)
{
sb.Append(" ");
sb.Append(' ');
sb.Append(bad.ToString());
if(--limit < 0)
break;
@@ -277,12 +276,12 @@ namespace OpenSim.Capabilities.Handlers
private void AddLibraryFolders(List<LLSDFetchInventoryDescendents> libFolders, List<InventoryCollection> result)
{
InventoryFolderImpl fold;
if (m_LibraryService == null || m_LibraryService.LibraryRootFolder == null)
if (m_LibraryService is null || m_LibraryService.LibraryRootFolder is null)
return;
foreach (LLSDFetchInventoryDescendents f in libFolders)
{
if ((fold = m_LibraryService.LibraryRootFolder.FindFolder(f.folder_id)) != null)
if ((fold = m_LibraryService.LibraryRootFolder.FindFolder(f.folder_id)) is not null)
{
InventoryCollection Collection = new InventoryCollection();
// ret.Collection.Folders = new List<InventoryFolderBase>();
@@ -357,7 +356,7 @@ namespace OpenSim.Capabilities.Handlers
InventoryCollection[] fetchedContents = m_InventoryService.GetMultipleFoldersContent(otherFolders[0].owner_id, otherIDs.ToArray());
if (fetchedContents == null)
if (fetchedContents is null)
return null;
if (fetchedContents.Length == 0)
@@ -413,7 +412,7 @@ namespace OpenSim.Capabilities.Handlers
if (contents.FolderID.IsZero())
{
InventoryFolderBase containingFolder = m_InventoryService.GetFolder(freq.owner_id, freq.folder_id);
if (containingFolder == null)
if (containingFolder is null)
{
bad_folders.Add(freq.folder_id);
return true;
@@ -428,7 +427,7 @@ namespace OpenSim.Capabilities.Handlers
private void ProcessLinks(LLSDFetchInventoryDescendents freq, InventoryCollection contents)
{
if (contents.Items == null || contents.Items.Count == 0)
if (contents.Items is null || contents.Items.Count == 0)
return;
// viewers are lasy and want a copy of the linked item sent before the link to it
@@ -447,7 +446,7 @@ namespace OpenSim.Capabilities.Handlers
{
InventoryItemBase[] linked = m_InventoryService.GetMultipleItems(freq.owner_id, itemIDs.ToArray());
if (linked != null)
if (linked is not null)
{
List<InventoryItemBase> linkedItems = new List<InventoryItemBase>(linked.Length);
// check for broken
@@ -457,7 +456,7 @@ namespace OpenSim.Capabilities.Handlers
// HACK: Also, don't follow up links that just point to other links. In theory this is legitimate,
// but no viewer has been observed to set these up and this is the lazy way of avoiding cycles
// rather than having to keep track of every folder requested in the recursion.
if (linkedItem != null && linkedItem.AssetType != (int)AssetType.Link)
if (linkedItem is not null && linkedItem.AssetType != (int)AssetType.Link)
{
linkedItems.Add(linkedItem);
//m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Added {0} {1} {2}", linkedItem.Name, linkedItem.AssetType, linkedItem.Folder);

View File

@@ -68,7 +68,7 @@ namespace OpenSim.Capabilities.Handlers
itemIDs[i++] = osdItemId["item_id"].AsUUID();
}
InventoryItemBase[] items = null;
InventoryItemBase[] items;
if (m_agentID.IsZero())
{
@@ -89,7 +89,7 @@ namespace OpenSim.Capabilities.Handlers
else
LLSDxmlEncode2.AddElem("agent_id", m_agentID, lsl);
if(items == null || items.Length == 0)
if(items is null || items.Length == 0)
{
LLSDxmlEncode2.AddEmptyArray("items", lsl);
}
@@ -98,7 +98,7 @@ namespace OpenSim.Capabilities.Handlers
LLSDxmlEncode2.AddArray("items", lsl);
foreach (InventoryItemBase item in items)
{
if (item != null)
if (item is not null)
item.ToLLSDxml(lsl, 0xff);
}
LLSDxmlEncode2.AddEndArray(lsl);

View File

@@ -84,15 +84,12 @@ namespace OpenSim.Capabilities.Handlers
itemIDs[i++] = id;
}
InventoryItemBase[] items = null;
//items = m_inventoryService.GetMultipleItems(libOwner, itemIDs);
items = m_LibraryService.GetMultipleItems(itemIDs);
InventoryItemBase[] items = m_LibraryService.GetMultipleItems(itemIDs);
osUTF8 lsl = LLSDxmlEncode2.Start(4096);
LLSDxmlEncode2.AddMap(lsl);
LLSDxmlEncode2.AddElem("agent_id", m_agentID, lsl);
if(items == null || items.Length == 0)
if(items is null || items.Length == 0)
{
LLSDxmlEncode2.AddEmptyArray("items", lsl);
}

View File

@@ -68,7 +68,7 @@ namespace OpenSim.Capabilities.Handlers
}
httpResponse.StatusCode = (int)HttpStatusCode.OK;
List<LLSDFetchInventoryDescendents> folders = null;
List<LLSDFetchInventoryDescendents> folders;
List<UUID> bad_folders = new List<UUID>();
try
{
@@ -77,10 +77,10 @@ namespace OpenSim.Capabilities.Handlers
httpRequest.InputStream.Dispose();
OSDMap map = (OSDMap)tmp;
if(map.TryGetValue("folders", out tmp) && tmp is OSDArray)
foldersrequested = tmp as OSDArray;
if(map.TryGetValue("folders", out tmp) && tmp is OSDArray frtmp)
foldersrequested = frtmp;
if (foldersrequested == null || foldersrequested.Count == 0)
if (foldersrequested is null || foldersrequested.Count == 0)
{
httpResponse.RawBuffer = EmptyResponse;
return;
@@ -125,7 +125,7 @@ namespace OpenSim.Capabilities.Handlers
return;
}
if (folders == null || folders.Count == 0)
if (folders is null || folders.Count == 0)
{
if(bad_folders.Count == 0)
{
@@ -234,7 +234,6 @@ namespace OpenSim.Capabilities.Handlers
invcollSet[i] = null;
}
LLSDxmlEncode2.AddEndArrayAndMap(lastresponse);
thiscoll = null;
}
else
{
@@ -260,7 +259,7 @@ namespace OpenSim.Capabilities.Handlers
int limit = 9;
foreach (UUID bad in bad_folders)
{
sb.Append(" ");
sb.Append(' ');
sb.Append(bad.ToString());
if(--limit < 0)
break;

File diff suppressed because it is too large Load Diff

View File

@@ -749,7 +749,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
LLUDPClient udpcli = this;
ThrottleOutPacketTypeFlags cats = categories;
Action<LLUDPClient, ThrottleOutPacketTypeFlags> act = delegate
void act(LLUDPClient arg1, ThrottleOutPacketTypeFlags arg2)
{
QueueEmpty callback = udpcli.OnQueueEmpty;
if (callback != null)
@@ -763,7 +763,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
udpcli.QueueEmptyRunning = false;
udpcli = null;
callback = null;
};
}
m_udpServer.OqrEngine.QueueJob(AgentID.ToString(), () => act(udpcli, cats));
}

View File

@@ -513,13 +513,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public void AddScene(IScene scene)
{
if (Scene != null)
if (Scene is not null)
{
m_log.Error("[LLUDPSERVER]: AddScene() called on an LLUDPServer that already has a scene");
return;
}
if (!(scene is Scene))
if (scene is not OpenSim.Region.Framework.Scenes.Scene)
{
m_log.Error($"[LLUDPSERVER]: AddScene() called with an unrecognized scene type {scene.GetType()}");
return;

View File

@@ -883,13 +883,10 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
/// </param>
public void PicksRequest(Object sender, string method, List<String> args)
{
if (!(sender is IClientAPI))
if (sender is not IClientAPI remoteClient)
return;
IClientAPI remoteClient = (IClientAPI)sender;
UUID targetId;
if(!UUID.TryParse(args[0], out targetId))
if(!UUID.TryParse(args[0], out UUID targetId))
return;
Dictionary<UUID, string> picks = new Dictionary<UUID, string>();

View File

@@ -109,7 +109,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
| GroupPowers.SendNotices
| GroupPowers.SetLandingPoint
| GroupPowers.StartProposal
| GroupPowers.VoteOnProposal;
| GroupPowers.VoteOnProposal
| GroupPowers.ExperienceAdmin
| GroupPowers.ExperienceCreator
| GroupPowers.GroupBanAccess
| GroupPowers.HostEvent;
private bool m_connectorEnabled = false;

View File

@@ -1551,15 +1551,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
bool curRunnning = instance.Running;
instance.m_Item.ScriptRunning = curRunnning;
IEventQueue eq = World.RequestModuleInterface<IEventQueue>();
if(eq == null)
{
controllingClient.SendScriptRunningReply(objectID, itemID, curRunnning);
}
else
{
eq.ScriptRunningEvent(objectID, itemID, curRunnning, controllingClient.AgentId);
}
controllingClient.SendScriptRunningReply(objectID, itemID, curRunnning);
}
}

View File

@@ -194,7 +194,7 @@ namespace OpenSim.Server.Base
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static byte[] SerializeResult(XmlSerializer xs, object data)
public static byte[] SerializeResult(XmlSerializer xs, object data)
{
using (MemoryStream ms = new MemoryStream())
using (XmlTextWriter xw = new XmlTextWriter(ms, Util.UTF8))
@@ -216,7 +216,7 @@ namespace OpenSim.Server.Base
/// <param name="dllName"></param>
/// <param name="args">The arguments which control which constructor is invoked on the plugin</param>
/// <returns></returns>
public static T LoadPlugin<T> (string dllName, Object[] args) where T:class
public static T LoadPlugin<T>(string dllName, Object[] args) where T : class
{
// This is good to debug configuration problems
//if (dllName.Length == 0)
@@ -225,19 +225,19 @@ namespace OpenSim.Server.Base
string className = String.Empty;
// The path for a dynamic plugin will contain ":" on Windows
string[] parts = dllName.Split (new char[] {':'});
string[] parts = dllName.Split(new char[] { ':' });
if (parts.Length < 3)
{
// Linux. There will be ':' but the one we're looking for
dllName = parts [0];
dllName = parts[0];
if (parts.Length > 1)
className = parts[1];
}
else
{
// This is Windows - we must replace the ":" in the path
dllName = String.Format ("{0}:{1}", parts [0], parts [1]);
dllName = String.Format("{0}:{1}", parts[0], parts[1]);
if (parts.Length > 2)
className = parts[2];
}
@@ -245,10 +245,10 @@ namespace OpenSim.Server.Base
// Handle extra string arguments in a more generic way
if (dllName.Contains("@"))
{
string[] dllNameParts = dllName.Split(new char[] {'@'});
string[] dllNameParts = dllName.Split(new char[] { '@' });
dllName = dllNameParts[dllNameParts.Length - 1];
List<Object> argList = new List<Object>(args);
for (int i = 0 ; i < dllNameParts.Length - 1 ; ++i)
for (int i = 0; i < dllNameParts.Length - 1; ++i)
argList.Add(dllNameParts[i]);
args = argList.ToArray();
@@ -264,7 +264,7 @@ namespace OpenSim.Server.Base
/// <param name="className"></param>
/// <param name="args">The arguments which control which constructor is invoked on the plugin</param>
/// <returns></returns>
public static T LoadPlugin<T>(string dllName, string className, Object[] args) where T:class
public static T LoadPlugin<T>(string dllName, string className, Object[] args) where T : class
{
string interfaceName = typeof(T).ToString();
@@ -327,7 +327,7 @@ namespace OpenSim.Server.Base
public static Dictionary<string, object> ParseQueryString(string query)
{
string[] terms = query.Split(new char[] {'&'});
string[] terms = query.Split(new char[] { '&' });
int nterms = terms.Length;
if (nterms == 0)
@@ -336,14 +336,14 @@ namespace OpenSim.Server.Base
Dictionary<string, object> result = new Dictionary<string, object>(nterms);
string name;
for(int i = 0; i < nterms; ++i)
for (int i = 0; i < nterms; ++i)
{
string[] elems = terms[i].Split(new char[] {'='});
string[] elems = terms[i].Split(new char[] { '=' });
if (elems.Length == 0)
continue;
if(String.IsNullOrWhiteSpace(elems[0]))
if (String.IsNullOrWhiteSpace(elems[0]))
continue;
name = System.Web.HttpUtility.UrlDecode(elems[0]);
@@ -351,18 +351,17 @@ namespace OpenSim.Server.Base
if (name.EndsWith("[]"))
{
name = name.Substring(0, name.Length - 2);
if(String.IsNullOrWhiteSpace(name))
if (String.IsNullOrWhiteSpace(name))
continue;
if (result.ContainsKey(name))
{
if (!(result[name] is List<string>))
if (result[name] is not List<string> l)
continue;
List<string> l = (List<string>)result[name];
if (elems.Length > 1 && !String.IsNullOrWhiteSpace(elems[1]))
if (elems.Length > 1 && !string.IsNullOrWhiteSpace(elems[1]))
l.Add(System.Web.HttpUtility.UrlDecode(elems[1]));
else
l.Add(String.Empty);
l.Add(string.Empty);
}
else
{
@@ -399,21 +398,20 @@ namespace OpenSim.Server.Base
foreach (KeyValuePair<string, object> kvp in data)
{
if (kvp.Value is List<string>)
if (kvp.Value is List<string> l)
{
List<string> l = (List<String>)kvp.Value;
int llen = l.Count;
string nkey = System.Web.HttpUtility.UrlEncode(kvp.Key);
for(int i = 0; i < llen; ++i)
for (int i = 0; i < llen; ++i)
{
if (sb.Length != 0)
sb.Append("&");
sb.Append('&');
sb.Append(nkey);
sb.Append("[]=");
sb.Append(System.Web.HttpUtility.UrlEncode(l[i]));
}
}
else if(kvp.Value is Dictionary<string, object>)
else if (kvp.Value is Dictionary<string, object>)
{
// encode complex structures as JSON
// needed for estate bans with the encoding used on xml
@@ -425,30 +423,30 @@ namespace OpenSim.Server.Base
// bypass libovm, we dont need even more useless high level maps
// this should only be called once.. but no problem, i hope
// (other uses may need more..)
LitJson.JsonMapper.RegisterExporter<UUID>((uuid, writer) => writer.Write(uuid.ToString()) );
LitJson.JsonMapper.RegisterExporter<UUID>((uuid, writer) => writer.Write(uuid.ToString()));
js = LitJson.JsonMapper.ToJson(kvp.Value);
}
// catch(Exception e)
// catch(Exception e)
catch
{
continue;
}
if (sb.Length != 0)
sb.Append("&");
sb.Append('&');
sb.Append(System.Web.HttpUtility.UrlEncode(kvp.Key));
sb.Append("=");
sb.Append('=');
sb.Append(System.Web.HttpUtility.UrlEncode(js));
}
else
{
if (sb.Length != 0)
sb.Append("&");
sb.Append('&');
sb.Append(System.Web.HttpUtility.UrlEncode(kvp.Key));
pvalue = kvp.Value.ToString();
if (!String.IsNullOrEmpty(pvalue))
if (!string.IsNullOrEmpty(pvalue))
{
sb.Append("=");
sb.Append('=');
sb.Append(System.Web.HttpUtility.UrlEncode(pvalue));
}
}
@@ -462,12 +460,11 @@ namespace OpenSim.Server.Base
{
XmlDocument doc = new XmlDocument();
XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
"", "");
XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, "", "");
doc.AppendChild(xmlnode);
XmlElement rootElement = doc.CreateElement("", "ServerResponse","");
XmlElement rootElement = doc.CreateElement("", "ServerResponse", "");
doc.AppendChild(rootElement);
@@ -480,26 +477,22 @@ namespace OpenSim.Server.Base
{
foreach (KeyValuePair<string, object> kvp in data)
{
if (kvp.Value == null)
if (kvp.Value is null)
continue;
XmlElement elem = parent.OwnerDocument.CreateElement("",
XmlConvert.EncodeLocalName(kvp.Key), "");
XmlElement elem = parent.OwnerDocument.CreateElement("", XmlConvert.EncodeLocalName(kvp.Key), "");
if (kvp.Value is Dictionary<string, object>)
if (kvp.Value is Dictionary<string, object> dic)
{
XmlAttribute type = parent.OwnerDocument.CreateAttribute("",
"type", "");
XmlAttribute type = parent.OwnerDocument.CreateAttribute("", "type", "");
type.Value = "List";
elem.Attributes.Append(type);
BuildXmlData(elem, (Dictionary<string, object>)kvp.Value);
BuildXmlData(elem, dic);
}
else
{
elem.AppendChild(parent.OwnerDocument.CreateTextNode(
kvp.Value.ToString()));
elem.AppendChild(parent.OwnerDocument.CreateTextNode(kvp.Value.ToString()));
}
parent.AppendChild(elem);
@@ -552,8 +545,8 @@ namespace OpenSim.Server.Base
xpc.Encoding = Util.UTF8NoBomEncoding;
using (XmlReader xr = XmlReader.Create(new StringReader(data), xset, xpc))
{
if(!xr.ReadToFollowing("ServerResponse"))
return new Dictionary<string, object>();
if (!xr.ReadToFollowing("ServerResponse"))
return new Dictionary<string, object>();
return ScanXmlResponse(xr);
}
}
@@ -612,7 +605,7 @@ namespace OpenSim.Server.Base
try
{
IConfigSource cs;
using( XmlReader r = XmlReader.Create(url))
using (XmlReader r = XmlReader.Create(url))
{
cs = new XmlConfigSource(r);
source.Merge(cs);

View File

@@ -306,8 +306,8 @@ namespace OpenSim.Services.InventoryService
public InventoryItemBase[] GetMultipleItems(UUID[] ids)
{
List<InventoryItemBase> items = new List<InventoryItemBase>();
foreach (UUID id in ids)
List<InventoryItemBase> items = new(ids.Length);
foreach (UUID id in ids.AsSpan())
{
if (m_items.TryGetValue(id, out InventoryItemBase it))
items.Add(it);