From 2bb6a50b0847e7b7b49166c2f4651f8d0eac21b3 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Wed, 5 Sep 2007 01:21:36 +0000 Subject: [PATCH] * Rewrote GiveMoney function and created several offspring Give*Money functions * Added GroupPowers enum courtesy of Thoys and switched GroupManager over to use it * Renamed Simulator.SimCaps to Simulator.Caps * Turned off Keep-Alive and Expect-100: Continue headers on Login * Added MoneyTransactionType and TransactionFlags git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@1391 52acb1d6-8a22-11de-b505-999d5b087335 --- VoiceTest/VoiceTest.cs | 2 +- importprimscript/importprimscript.cs | 2 +- libsecondlife/GroupManager.cs | 69 ++++++- libsecondlife/Login.cs | 3 + libsecondlife/MainAvatar.cs | 180 +++++++++++++++--- libsecondlife/Settings.cs | 8 + libsecondlife/Simulator.cs | 23 +-- .../Commands/Inventory/GiveAllCommand.cs | 2 +- .../examples/groupmanager/frmGroupInfo.cs | 2 +- .../examples/slaccountant/frmSLAccountant.cs | 2 +- .../libsecondlife.Utilities/VoiceManager.cs | 4 +- 11 files changed, 241 insertions(+), 56 deletions(-) diff --git a/VoiceTest/VoiceTest.cs b/VoiceTest/VoiceTest.cs index faf7865f..67deb227 100644 --- a/VoiceTest/VoiceTest.cs +++ b/VoiceTest/VoiceTest.cs @@ -88,7 +88,7 @@ namespace VoiceTest Console.WriteLine("Voice connector handle: " + connectorHandle); // Wait for the simulator capabilities to show up - client.Network.CurrentSim.SimCaps.CapsReceivedEvent.WaitOne(45 * 1000, false); + client.Network.CurrentSim.Caps.CapsReceivedEvent.WaitOne(45 * 1000, false); Console.WriteLine("Asking the current simulator to create a provisional account..."); diff --git a/importprimscript/importprimscript.cs b/importprimscript/importprimscript.cs index 03eccdec..09104f79 100644 --- a/importprimscript/importprimscript.cs +++ b/importprimscript/importprimscript.cs @@ -196,7 +196,7 @@ namespace importprimscript if (CurrentUpload.Success) { // Pay for the upload - Client.Self.GiveMoney(LLUUID.Zero, Client.Settings.UPLOAD_COST, "importprimscript"); + Client.Self.PayUploadFee("importprimscript"); Console.WriteLine("Finished uploading image " + filename + ", AssetID: " + CurrentUpload.AssetID.ToStringHyphenated()); diff --git a/libsecondlife/GroupManager.cs b/libsecondlife/GroupManager.cs index f094430a..45be65ca 100644 --- a/libsecondlife/GroupManager.cs +++ b/libsecondlife/GroupManager.cs @@ -44,7 +44,7 @@ namespace libsecondlife /// Online status information public string OnlineStatus; /// Abilities that the Group Member has - public ulong Powers; + public GroupPowers Powers; /// Current group title public string Title; /// Is a group owner @@ -65,7 +65,7 @@ namespace libsecondlife /// Description of Role public string Description; /// Abilities Associated with Role - public ulong Powers; + public GroupPowers Powers; /// /// Returns the role's title /// @@ -111,7 +111,7 @@ namespace libsecondlife /// Will group show up in search public bool ShowInList; /// - public ulong Powers; + public GroupPowers Powers; /// public bool AcceptNotices; /// @@ -163,7 +163,7 @@ namespace libsecondlife /// public bool ShowInList; /// - public ulong Powers; + public GroupPowers Powers; /// public bool AcceptNotices; /// @@ -397,6 +397,55 @@ namespace libsecondlife VoteOnProposal = 1 << 45 } + [Flags] + public enum GroupPowers : ulong + { + MemberInvite = 2, + MemberEject = 4, + MemberOptions = 8, + MemberVisibleInDir = 140737488355328, + RoleCreate = 16, + RoleDelete = 32, + RoleProperties = 64, + RoleAssignMemberLimited = 128, + RoleAssignMember = 256, + RoleRemoveMember = 512, + RoleChangeActions = 1024, + GroupChangeIdentity = 2048, + LandDeed = 4096, + LandRelease = 8192, + LandSetSaleInfo = 16384, + LandDivideJoin = 32768, + LandFindPlaces = 131072, + LandChangeIdentity = 262144, + LandSetLandingPoint = 524288, + LandChangeMedia = 1048576, + LandEdit = 2097152, + LandOptions = 4194304, + LandAllowEditLand = 8388608, + LandAllowFly = 16777216, + LandAllowCreate = 33554432, + LandAllowLandmark = 67108864, + LandAllowSetHome = 268435456, + LandManageAllowed = 536870912, + LandManageBanned = 1073741824, + LandManagePasses = 2147483648, + LandAdmin = 4294967296, + LandReturnGroupOwned = 281474976710656, + LandReturnGroupSet = 8589934592, + LandReturnNonGroup = 17179869184, + LandReturn = LandReturnGroupOwned | LandReturnGroupSet | LandReturnNonGroup, + LandGardening = 34359738368, + ObjectDeed = 68719476736, + ObjectManipulate = 274877906944, + ObjectSetSale = 549755813888, + AccountingAccountable = 1099511627776, + NoticesSend = 4398046511104, + NoticesReceive = 8796093022208, + ProposalStart = 17592186044416, + ProposalVote = 35184372088832 + } + #endregion Enums /// @@ -846,7 +895,7 @@ namespace libsecondlife gru.RoleData = new GroupRoleUpdatePacket.RoleDataBlock[1]; gru.RoleData[0].Name = Helpers.StringToField(role.Name); gru.RoleData[0].Description = Helpers.StringToField(role.Description); - gru.RoleData[0].Powers = role.Powers; + gru.RoleData[0].Powers = (ulong)role.Powers; gru.RoleData[0].Title = Helpers.StringToField(role.Title); gru.RoleData[0].UpdateType = (byte)GroupRoleUpdate.UpdateAll; Client.Network.SendPacket(gru); @@ -866,7 +915,7 @@ namespace libsecondlife gru.RoleData = new GroupRoleUpdatePacket.RoleDataBlock[1]; gru.RoleData[0].Name = Helpers.StringToField(role.Name); gru.RoleData[0].Description = Helpers.StringToField(role.Description); - gru.RoleData[0].Powers = role.Powers; + gru.RoleData[0].Powers = (ulong)role.Powers; gru.RoleData[0].Title = Helpers.StringToField(role.Title); gru.RoleData[0].UpdateType = (byte)GroupRoleUpdate.Create; Client.Network.SendPacket(gru); @@ -976,7 +1025,7 @@ namespace libsecondlife group.ID = block.GroupID; group.InsigniaID = block.GroupInsigniaID; group.Name = Helpers.FieldToUTF8String(block.GroupName); - group.Powers = block.GroupPowers; + group.Powers = (GroupPowers)block.GroupPowers; group.Contribution = block.Contribution; group.AcceptNotices = block.AcceptNotices; @@ -1018,7 +1067,7 @@ namespace libsecondlife group.Name = Helpers.FieldToUTF8String(profile.GroupData.Name); group.OpenEnrollment = profile.GroupData.OpenEnrollment; group.OwnerRole = profile.GroupData.OwnerRole; - group.Powers = profile.GroupData.PowersMask; + group.Powers = (GroupPowers)profile.GroupData.PowersMask; group.ShowInList = profile.GroupData.ShowInList; try { OnGroupProfile(group); } @@ -1068,7 +1117,7 @@ namespace libsecondlife groupMember.Contribution = block.Contribution; groupMember.IsOwner = block.IsOwner; groupMember.OnlineStatus = Helpers.FieldToUTF8String(block.OnlineStatus); - groupMember.Powers = block.AgentPowers; + groupMember.Powers = (GroupPowers)block.AgentPowers; groupMember.Title = Helpers.FieldToUTF8String(block.Title); groupMemberCache[block.AgentID] = groupMember; @@ -1103,7 +1152,7 @@ namespace libsecondlife groupRole.ID = block.RoleID; groupRole.Description = Helpers.FieldToUTF8String(block.Description); groupRole.Name = Helpers.FieldToUTF8String(block.Name); - groupRole.Powers = block.Powers; + groupRole.Powers = (GroupPowers)block.Powers; groupRole.Title = Helpers.FieldToUTF8String(block.Title); groupRoleCache[block.RoleID] = groupRole; diff --git a/libsecondlife/Login.cs b/libsecondlife/Login.cs index cf84fa2d..d2257ace 100644 --- a/libsecondlife/Login.cs +++ b/libsecondlife/Login.cs @@ -485,9 +485,12 @@ namespace libsecondlife try { ILoginProxy proxy = XmlRpcProxyGen.Create(); + proxy.KeepAlive = false; + proxy.Expect100Continue = false; proxy.ResponseEvent += new XmlRpcResponseEventHandler(proxy_ResponseEvent); proxy.Url = CurrentContext.Params.URI; proxy.XmlRpcMethod = CurrentContext.Params.MethodName; // make sure this isnt evil. + // Start the request proxy.BeginLoginToSimulator(loginParams, new AsyncCallback(LoginMethodCallback), new object[] { proxy, CurrentContext }); } diff --git a/libsecondlife/MainAvatar.cs b/libsecondlife/MainAvatar.cs index 15ea2fdf..77db5387 100644 --- a/libsecondlife/MainAvatar.cs +++ b/libsecondlife/MainAvatar.cs @@ -237,34 +237,34 @@ namespace libsecondlife /// public enum EffectType : byte { - /// Place floating text above an object + /// Text = 0, - /// Unknown, probably places an icon above an object + /// Icon, - /// Unknown + /// Connector, - /// Unknown + /// FlexibleObject, - /// Unknown + /// AnimalControls, - /// Unknown + /// AnimationObject, - /// Unknown + /// Cloth, /// Project a beam from a source to a destination, such as /// the one used when editing an object Beam, - /// Not implemented yet + /// Glow, - /// Unknown + /// Point, - /// Unknown + /// Trail, /// Create a swirl of particles around an object Sphere, - /// Unknown + /// Spiral, - /// Unknown + /// Edit, /// Cause an avatar to look at an object LookAt, @@ -291,6 +291,7 @@ namespace libsecondlife /// Hover, /// Deprecated + [Obsolete] Conversation, /// Select, @@ -318,6 +319,71 @@ namespace libsecondlife Clear } + public enum MoneyTransactionType : int + { + None = 0, + FailSimulatorTimeout = 1, + FailDataserverTimeout = 2, + ObjectClaim = 1000, + LandClaim = 1001, + GroupCreate = 1002, + ObjectPublicClaim = 1003, + GroupJoin = 1004, + TeleportCharge = 1100, + UploadCharge = 1101, + LandAuction = 1102, + ClassifiedCharge = 1103, + ObjectTax = 2000, + LandTax = 2001, + LightTax = 2002, + ParcelDirFee = 2003, + GroupTax = 2004, + ClassifiedRenew = 2005, + GiveInventory = 3000, + ObjectSale = 5000, + Gift = 5001, + LandSale = 5002, + ReferBonus = 5003, + InventorySale = 5004, + RefundPurchase = 5005, + LandPassSale = 5006, + DwellBonus = 5007, + PayObject = 5008, + ObjectPays = 5009, + GroupLandDeed = 6001, + GroupObjectDeed = 6002, + GroupLiability = 6003, + GroupDividend = 6004, + GroupMembershipDues = 6005, + ObjectRelease = 8000, + LandRelease = 8001, + ObjectDelete = 8002, + ObjectPublicDecay = 8003, + ObjectPublicDelete = 8004, + LindenAdjustment = 9000, + LindenGrant = 9001, + LindenPenalty = 9002, + EventFee = 9003, + EventPrize = 9004, + StipendBasic = 10000, + StipendDeveloper = 10001, + StipendAlways = 10002, + StipendDaily = 10003, + StipendRating = 10004, + StipendDelta = 10005 + } + + [Flags] + public enum TransactionFlags : byte + { + None = 0, + SourceGroup = 1, + DestGroup = 2, + OwnerGroup = 4, + SimultaneousContribution = 8, + ContributionRemoval = 16 + } + #endregion Enums #region Structs @@ -1003,7 +1069,6 @@ namespace libsecondlife duration = 4.0f; break; case LookAtType.None: - case LookAtType.Conversation: case LookAtType.Select: case LookAtType.Focus: case LookAtType.Mouselook: @@ -1318,14 +1383,72 @@ namespace libsecondlife /// /// UUID of the Target Avatar /// Amount in L$ - /// Reason (optional normally) - public void GiveMoney(LLUUID target, int amount, string description) + public void GiveAvatarMoney(LLUUID target, int amount) { - // 5001 - transaction type for av to av money transfers - if (amount > 0) - GiveMoney(target, amount, description, 5001); - else - Client.Log("Attempted to pay zero or negative value " + amount, Helpers.LogLevel.Warning); + GiveMoney(target, amount, String.Empty, MoneyTransactionType.Gift, TransactionFlags.None); + } + + /// + /// Give Money to destination Avatar + /// + /// UUID of the Target Avatar + /// Amount in L$ + /// Description that will show up in the + /// recipients transaction history + public void GiveAvatarMoney(LLUUID target, int amount, string description) + { + GiveMoney(target, amount, description, MoneyTransactionType.Gift, TransactionFlags.None); + } + + /// + /// + /// + /// + /// + /// + public void GiveObjectMoney(LLUUID target, int amount, string objectName) + { + GiveMoney(target, amount, objectName, MoneyTransactionType.PayObject, TransactionFlags.None); + } + + /// + /// + /// + /// + /// + public void GiveGroupMoney(LLUUID target, int amount) + { + GiveMoney(target, amount, String.Empty, MoneyTransactionType.Gift, TransactionFlags.DestGroup); + } + + /// + /// + /// + /// + /// + /// + public void GiveGroupMoney(LLUUID target, int amount, string description) + { + GiveMoney(target, amount, description, MoneyTransactionType.Gift, TransactionFlags.DestGroup); + } + + /// + /// + /// + public void PayUploadFee() + { + GiveMoney(LLUUID.Zero, Client.Settings.UPLOAD_COST, String.Empty, MoneyTransactionType.UploadCharge, + TransactionFlags.None); + } + + /// + /// + /// + /// + public void PayUploadFee(string description) + { + GiveMoney(LLUUID.Zero, Client.Settings.UPLOAD_COST, description, MoneyTransactionType.UploadCharge, + TransactionFlags.None); } /// @@ -1334,9 +1457,10 @@ namespace libsecondlife /// UUID of the Target Object/Avatar /// Amount in L$ /// Reason (Optional normally) - /// The type of transaction. Currently only 5001 is - /// documented for Av->Av money transfers. - public void GiveMoney(LLUUID target, int amount, string description, int transactiontype) + /// The type of transaction + /// Transaction flags, mostly for identifying group + /// transactions + public void GiveMoney(LLUUID target, int amount, string description, MoneyTransactionType type, TransactionFlags flags) { MoneyTransferRequestPacket money = new MoneyTransferRequestPacket(); money.AgentData.AgentID = this.ID; @@ -1344,10 +1468,10 @@ namespace libsecondlife money.MoneyData.Description = Helpers.StringToField(description); money.MoneyData.DestID = target; money.MoneyData.SourceID = this.ID; - money.MoneyData.TransactionType = transactiontype; - money.MoneyData.AggregatePermInventory = 0; //TODO: whats this? - money.MoneyData.AggregatePermNextOwner = 0; //TODO: whats this? - money.MoneyData.Flags = 0; //TODO: whats this? + money.MoneyData.TransactionType = (int)type; + money.MoneyData.AggregatePermInventory = 0; // This is weird, apparently always set to zero though + money.MoneyData.AggregatePermNextOwner = 0; // This is weird, apparently always set to zero though + money.MoneyData.Flags = (byte)flags; money.MoneyData.Amount = amount; Client.Network.SendPacket(money); @@ -1640,7 +1764,7 @@ namespace libsecondlife /// Target to look at public void RequestTeleport(ulong regionHandle, LLVector3 position, LLVector3 lookAt) { - if (Client.Network.CurrentSim != null && Client.Network.CurrentSim.SimCaps != null && Client.Network.CurrentSim.SimCaps.IsEventQueueRunning) + if (Client.Network.CurrentSim != null && Client.Network.CurrentSim.Caps != null && Client.Network.CurrentSim.Caps.IsEventQueueRunning) { TeleportLocationRequestPacket teleport = new TeleportLocationRequestPacket(); teleport.AgentData.AgentID = Client.Network.AgentID; diff --git a/libsecondlife/Settings.cs b/libsecondlife/Settings.cs index 735dd069..4580439a 100644 --- a/libsecondlife/Settings.cs +++ b/libsecondlife/Settings.cs @@ -51,6 +51,9 @@ namespace libsecondlife // Timeouts + /// Number of milliseconds before an asset transfer will time + /// out + public const int TRANSFER_TIMEOUT = 30 * 1000; /// Number of milliseconds before a teleport attempt will time /// out public int TELEPORT_TIMEOUT = 40 * 1000; @@ -170,6 +173,11 @@ namespace libsecondlife /// an object update packet is received public bool OBJECT_TRACKING = true; + // Misc + + /// Default color used for viewer particle effects + public LLColor DEFAULT_EFFECT_COLOR = new LLColor(255, 0, 0, 255); + /// Cost of uploading an asset /// Read-only since this value is dynamically fetched at login public int UPLOAD_COST { get { return priceUpload; } } diff --git a/libsecondlife/Simulator.cs b/libsecondlife/Simulator.cs index d646e4d8..4677e009 100644 --- a/libsecondlife/Simulator.cs +++ b/libsecondlife/Simulator.cs @@ -207,7 +207,7 @@ namespace libsecondlife /// public LLUUID ID = LLUUID.Zero; /// The capabilities for this simulator - public Capabilities SimCaps = null; + public Capabilities Caps = null; /// public ulong Handle; /// @@ -358,9 +358,9 @@ namespace libsecondlife public void Dispose() { // Force all the CAPS connections closed for this simulator - if (SimCaps != null) + if (Caps != null) { - SimCaps.Disconnect(true); + Caps.Disconnect(true); } } @@ -430,20 +430,20 @@ namespace libsecondlife public void SetSeedCaps(string seedcaps) { - if (SimCaps != null) + if (Caps != null) { - if (SimCaps._SeedCapsURI == seedcaps) return; + if (Caps._SeedCapsURI == seedcaps) return; Client.Log("Unexpected change of seed capability", Helpers.LogLevel.Warning); - SimCaps.Disconnect(true); - SimCaps = null; + Caps.Disconnect(true); + Caps = null; } if (Client.Settings.ENABLE_CAPS) { // Connect to the new CAPS system if (!String.IsNullOrEmpty(seedcaps)) - SimCaps = new Capabilities(this, seedcaps); + Caps = new Capabilities(this, seedcaps); else Client.Log("Setting up a sim without a valid capabilities server!", Helpers.LogLevel.Error); } @@ -464,10 +464,10 @@ namespace libsecondlife if (Client.Settings.SEND_PINGS) PingTimer.Stop(); // Kill the current CAPS system - if (SimCaps != null) + if (Caps != null) { - SimCaps.Disconnect(true); - SimCaps = null; + Caps.Disconnect(true); + Caps = null; } if (sendCloseCircuit) @@ -824,6 +824,7 @@ namespace libsecondlife packet.Header.Sequence, packet.GetType(), now - packet.TickCount)); packet.Header.Resent = true; + packet.TickCount = now; ++Stats.ResentPackets; SendPacket(packet, false); } diff --git a/libsecondlife/examples/TestClient/Commands/Inventory/GiveAllCommand.cs b/libsecondlife/examples/TestClient/Commands/Inventory/GiveAllCommand.cs index fe42fcee..b203a403 100644 --- a/libsecondlife/examples/TestClient/Commands/Inventory/GiveAllCommand.cs +++ b/libsecondlife/examples/TestClient/Commands/Inventory/GiveAllCommand.cs @@ -20,7 +20,7 @@ namespace libsecondlife.TestClient return "Unable to send money to console. This command only works when IMed."; int amount = Client.Self.Balance; - Client.Self.GiveMoney(fromAgentID, Client.Self.Balance, String.Empty); + Client.Self.GiveAvatarMoney(fromAgentID, Client.Self.Balance, "TestClient.GiveAll"); return "Gave $" + amount + " to " + fromAgentID; } } diff --git a/libsecondlife/examples/groupmanager/frmGroupInfo.cs b/libsecondlife/examples/groupmanager/frmGroupInfo.cs index 97c502b4..2fe1ec83 100644 --- a/libsecondlife/examples/groupmanager/frmGroupInfo.cs +++ b/libsecondlife/examples/groupmanager/frmGroupInfo.cs @@ -218,7 +218,7 @@ namespace groupmanager memberData.ID = member.ID; memberData.IsOwner = member.IsOwner; memberData.LastOnline = member.OnlineStatus; - memberData.Powers = member.Powers; + memberData.Powers = (ulong)member.Powers; memberData.Title = member.Title; memberData.Contribution = member.Contribution; diff --git a/libsecondlife/examples/slaccountant/frmSLAccountant.cs b/libsecondlife/examples/slaccountant/frmSLAccountant.cs index 8ad6a3ce..cb6c9f3b 100644 --- a/libsecondlife/examples/slaccountant/frmSLAccountant.cs +++ b/libsecondlife/examples/slaccountant/frmSLAccountant.cs @@ -496,7 +496,7 @@ namespace SLAccountant return; } - client.Self.GiveMoney(new LLUUID(lstFind.SelectedItems[0].SubItems[2].Text), + client.Self.GiveAvatarMoney(new LLUUID(lstFind.SelectedItems[0].SubItems[2].Text), amount, "SLAccountant payment"); } } diff --git a/libsecondlife/libsecondlife.Utilities/VoiceManager.cs b/libsecondlife/libsecondlife.Utilities/VoiceManager.cs index 0a731221..b8d690f1 100644 --- a/libsecondlife/libsecondlife.Utilities/VoiceManager.cs +++ b/libsecondlife/libsecondlife.Utilities/VoiceManager.cs @@ -320,9 +320,9 @@ namespace libsecondlife.Utilities { if (Enabled && Client.Network.Connected) { - if (Client.Network.CurrentSim != null && Client.Network.CurrentSim.SimCaps != null) + if (Client.Network.CurrentSim != null && Client.Network.CurrentSim.Caps != null) { - string requestURI = Client.Network.CurrentSim.SimCaps.CapabilityURI("ProvisionVoiceAccountRequest"); + string requestURI = Client.Network.CurrentSim.Caps.CapabilityURI("ProvisionVoiceAccountRequest"); if (requestURI != String.Empty) {