diff options
Diffstat (limited to 'tools/mass test client/Commands/CloneProfileCommand.cs')
-rw-r--r-- | tools/mass test client/Commands/CloneProfileCommand.cs | 131 |
1 files changed, 0 insertions, 131 deletions
diff --git a/tools/mass test client/Commands/CloneProfileCommand.cs b/tools/mass test client/Commands/CloneProfileCommand.cs deleted file mode 100644 index e475655..0000000 --- a/tools/mass test client/Commands/CloneProfileCommand.cs +++ /dev/null | |||
@@ -1,131 +0,0 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Threading; | ||
4 | using libsecondlife; | ||
5 | using libsecondlife.Packets; | ||
6 | |||
7 | namespace libsecondlife.TestClient | ||
8 | { | ||
9 | public class CloneProfileCommand : Command | ||
10 | { | ||
11 | Avatar.AvatarProperties Properties; | ||
12 | Avatar.Interests Interests; | ||
13 | List<LLUUID> Groups = new List<LLUUID>(); | ||
14 | bool ReceivedProperties = false; | ||
15 | bool ReceivedInterests = false; | ||
16 | bool ReceivedGroups = false; | ||
17 | ManualResetEvent ReceivedProfileEvent = new ManualResetEvent(false); | ||
18 | |||
19 | public CloneProfileCommand(TestClient testClient) | ||
20 | { | ||
21 | testClient.Avatars.OnAvatarInterests += new AvatarManager.AvatarInterestsCallback(Avatars_OnAvatarInterests); | ||
22 | testClient.Avatars.OnAvatarProperties += new AvatarManager.AvatarPropertiesCallback(Avatars_OnAvatarProperties); | ||
23 | testClient.Avatars.OnAvatarGroups += new AvatarManager.AvatarGroupsCallback(Avatars_OnAvatarGroups); | ||
24 | testClient.Self.OnJoinGroup += new MainAvatar.JoinGroupCallback(Self_OnJoinGroup); | ||
25 | |||
26 | Name = "cloneprofile"; | ||
27 | Description = "Clones another avatars profile as closely as possible. WARNING: This command will " + | ||
28 | "destroy your existing profile! Usage: cloneprofile [targetuuid]"; | ||
29 | } | ||
30 | |||
31 | public override string Execute(string[] args, LLUUID fromAgentID) | ||
32 | { | ||
33 | if (args.Length != 1) | ||
34 | return Description; | ||
35 | |||
36 | LLUUID targetID; | ||
37 | ReceivedProperties = false; | ||
38 | ReceivedInterests = false; | ||
39 | ReceivedGroups = false; | ||
40 | |||
41 | try | ||
42 | { | ||
43 | targetID = new LLUUID(args[0]); | ||
44 | } | ||
45 | catch (Exception) | ||
46 | { | ||
47 | return Description; | ||
48 | } | ||
49 | |||
50 | // Request all of the packets that make up an avatar profile | ||
51 | Client.Avatars.RequestAvatarProperties(targetID); | ||
52 | |||
53 | // Wait for all the packets to arrive | ||
54 | ReceivedProfileEvent.Reset(); | ||
55 | ReceivedProfileEvent.WaitOne(5000, false); | ||
56 | |||
57 | // Check if everything showed up | ||
58 | if (!ReceivedInterests || !ReceivedProperties || !ReceivedGroups) | ||
59 | return "Failed to retrieve a complete profile for that UUID"; | ||
60 | |||
61 | // Synchronize our profile | ||
62 | Client.Self.ProfileInterests = Interests; | ||
63 | Client.Self.ProfileProperties = Properties; | ||
64 | Client.Self.SetAvatarInformation(); | ||
65 | |||
66 | // TODO: Leave all the groups we're currently a member of? This could | ||
67 | // break TestClient connectivity that might be relying on group authentication | ||
68 | |||
69 | // Attempt to join all the groups | ||
70 | foreach (LLUUID groupID in Groups) | ||
71 | { | ||
72 | Client.Self.RequestJoinGroup(groupID); | ||
73 | } | ||
74 | |||
75 | return "Synchronized our profile to the profile of " + targetID.ToStringHyphenated(); | ||
76 | } | ||
77 | |||
78 | void Avatars_OnAvatarProperties(LLUUID avatarID, Avatar.AvatarProperties properties) | ||
79 | { | ||
80 | lock (ReceivedProfileEvent) | ||
81 | { | ||
82 | Properties = properties; | ||
83 | ReceivedProperties = true; | ||
84 | |||
85 | if (ReceivedInterests && ReceivedProperties && ReceivedGroups) | ||
86 | ReceivedProfileEvent.Set(); | ||
87 | } | ||
88 | } | ||
89 | |||
90 | void Avatars_OnAvatarInterests(LLUUID avatarID, Avatar.Interests interests) | ||
91 | { | ||
92 | lock (ReceivedProfileEvent) | ||
93 | { | ||
94 | Interests = interests; | ||
95 | ReceivedInterests = true; | ||
96 | |||
97 | if (ReceivedInterests && ReceivedProperties && ReceivedGroups) | ||
98 | ReceivedProfileEvent.Set(); | ||
99 | } | ||
100 | } | ||
101 | |||
102 | void Avatars_OnAvatarGroups(LLUUID avatarID, AvatarGroupsReplyPacket.GroupDataBlock[] groups) | ||
103 | { | ||
104 | lock (ReceivedProfileEvent) | ||
105 | { | ||
106 | foreach (AvatarGroupsReplyPacket.GroupDataBlock block in groups) | ||
107 | { | ||
108 | Groups.Add(block.GroupID); | ||
109 | } | ||
110 | |||
111 | ReceivedGroups = true; | ||
112 | |||
113 | if (ReceivedInterests && ReceivedProperties && ReceivedGroups) | ||
114 | ReceivedProfileEvent.Set(); | ||
115 | } | ||
116 | } | ||
117 | |||
118 | void Self_OnJoinGroup(LLUUID groupID, bool success) | ||
119 | { | ||
120 | Console.WriteLine(Client.ToString() + (success ? " joined " : " failed to join ") + | ||
121 | groupID.ToStringHyphenated()); | ||
122 | |||
123 | if (success) | ||
124 | { | ||
125 | Console.WriteLine(Client.ToString() + " setting " + groupID.ToStringHyphenated() + | ||
126 | " as the active group"); | ||
127 | Client.Self.ActivateGroup(groupID); | ||
128 | } | ||
129 | } | ||
130 | } | ||
131 | } | ||