diff --git a/libsecondlife-cs/EstateTools.cs b/libsecondlife-cs/EstateTools.cs
index 82e3c6cd..189ebd58 100644
--- a/libsecondlife-cs/EstateTools.cs
+++ b/libsecondlife-cs/EstateTools.cs
@@ -29,7 +29,7 @@ using libsecondlife.Packets;
namespace libsecondlife
{
///
- /// Summary description for EstateTools.
+ ///
///
public class EstateTools
{
diff --git a/libsecondlife-cs/GroupManager.cs b/libsecondlife-cs/GroupManager.cs
index 4b18ca71..8638ea01 100644
--- a/libsecondlife-cs/GroupManager.cs
+++ b/libsecondlife-cs/GroupManager.cs
@@ -63,6 +63,12 @@ namespace libsecondlife
}
}
+ public class GroupTitle
+ {
+ public string Title;
+ public bool Selected;
+ }
+
///
/// Represents a group in Second Life
///
@@ -86,31 +92,11 @@ namespace libsecondlife
public int Contribution;
public int GroupMembershipCount;
public int GroupRolesCount;
- ///
- public Dictionary Titles;
- /// List of all the roles in this group
- public Dictionary Roles;
- /// List of all the members in this group
- public Dictionary Members;
- /// Used for internal state tracking
- public LLUUID TitlesRequestID;
- /// Used for internal state tracking
- public LLUUID RolesRequestID;
- /// Used for internal state tracking
- public LLUUID MembersRequestID;
public Group(LLUUID id)
{
ID = id;
InsigniaID = new LLUUID();
-
- Titles = new Dictionary();
- Roles = new Dictionary();
- Members = new Dictionary();
-
- TitlesRequestID = new LLUUID();
- RolesRequestID = new LLUUID();
- MembersRequestID = new LLUUID();
}
public override string ToString()
@@ -119,29 +105,92 @@ namespace libsecondlife
}
}
+ public class GroupProfile
+ {
+ public LLUUID ID;
+ public LLUUID InsigniaID;
+ public LLUUID FounderID;
+ public LLUUID OwnerRole;
+ public string Name;
+ public string Charter;
+ public string MemberTitle;
+ public bool OpenEnrollment;
+ public bool ShowInList;
+ public ulong Powers;
+ public bool AcceptNotices;
+ public bool AllowPublish;
+ public bool MaturePublish;
+ public int MembershipFee;
+ public int Money;
+ public int Contribution;
+ public int GroupMembershipCount;
+ public int GroupRolesCount;
+ }
+
+ ///
+ /// Handles all network traffic related to reading and writing group
+ /// information
+ ///
public class GroupManager
{
///
- /// Called whenever the group membership list is updated
+ /// Callback for the list of groups the avatar is currently a member of
///
///
- public delegate void GroupsUpdatedCallback();
-
- ///
- public Dictionary Groups;
- private Mutex GroupsMutex;
-
- /// Called whenever the group membership list is updated
- public event GroupsUpdatedCallback OnGroupsUpdated;
+ public delegate void CurrentGroupsCallback(Dictionary groups);
+ ///
+ /// Callback for the profile of a group
+ ///
+ ///
+ public delegate void GroupProfileCallback(GroupProfile group);
+ ///
+ /// Callback for the member list of a group
+ ///
+ ///
+ public delegate void GroupMembersCallback(Dictionary members);
+ ///
+ /// Callback for the role list of a group
+ ///
+ ///
+ public delegate void GroupRolesCallback(Dictionary roles);
+ ///
+ /// Callback for the title list of a group
+ ///
+ ///
+ public delegate void GroupTitlesCallback(Dictionary titles);
private SecondLife Client;
-
+ // No need for concurrency with the current group list request
+ private CurrentGroupsCallback OnCurrentGroups;
+ private Dictionary GroupProfileCallbacks;
+ private Dictionary GroupMembersCallbacks;
+ private Dictionary GroupRolesCallbacks;
+ private Dictionary GroupTitlesCallbacks;
+ /// A list of all the lists of group members, indexed by the request ID
+ private Dictionary> GroupMembersCaches;
+ private Mutex GroupMembersCachesMutex;
+ /// A list of all the lists of group roles, indexed by the request ID
+ private Dictionary> GroupRolesCaches;
+ private Mutex GroupRolesCachesMutex;
+
+ ///
+ ///
+ ///
+ ///
public GroupManager(SecondLife client)
{
- Groups = new Dictionary();
- GroupsMutex = new Mutex(false, "GroupsMutex");
Client = client;
+ GroupProfileCallbacks = new Dictionary();
+ GroupMembersCallbacks = new Dictionary();
+ GroupRolesCallbacks = new Dictionary();
+ GroupTitlesCallbacks = new Dictionary();
+
+ GroupMembersCaches = new Dictionary>();
+ GroupMembersCachesMutex = new Mutex(false, "GroupMembersCachesMutex");
+ GroupRolesCaches = new Dictionary>();
+ GroupRolesCachesMutex = new Mutex(false, "GroupRolesCachesMutex");
+
Client.Network.RegisterCallback(PacketType.AgentGroupDataUpdate, new PacketCallback(GroupDataHandler));
Client.Network.RegisterCallback(PacketType.GroupTitlesReply, new PacketCallback(GroupTitlesHandler));
Client.Network.RegisterCallback(PacketType.GroupProfileReply, new PacketCallback(GroupProfileHandler));
@@ -155,245 +204,227 @@ namespace libsecondlife
Client.Network.RegisterCallback(PacketType.GroupAccountTransactionsReply, new PacketCallback(GroupAccountTransactionsHandler));
}
+ ///
+ ///
+ ///
+ ///
+ public void BeginGetCurrentGroups(CurrentGroupsCallback cgc)
+ {
+ OnCurrentGroups = cgc;
+
+ AgentDataUpdateRequestPacket request = new AgentDataUpdateRequestPacket();
+
+ request.AgentData.AgentID = Client.Network.AgentID;
+ request.AgentData.SessionID = Client.Network.SessionID;
+
+ Client.Network.SendPacket(request);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public void BeginGetGroupProfile(LLUUID group, GroupProfileCallback gpc)
+ {
+ GroupProfileCallbacks[group] = gpc;
+
+ GroupProfileRequestPacket request = new GroupProfileRequestPacket();
+
+ request.AgentData.AgentID = Client.Network.AgentID;
+ request.AgentData.SessionID = Client.Network.SessionID;
+ request.GroupData.GroupID = group;
+
+ Client.Network.SendPacket(request);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public void BeginGetGroupMembers(LLUUID group, GroupMembersCallback gmc)
+ {
+ LLUUID requestID = LLUUID.GenerateUUID();
+
+ #region GroupMembersCachesMutex
+ GroupMembersCachesMutex.WaitOne();
+ GroupMembersCaches[requestID] = new Dictionary();
+ GroupMembersCachesMutex.ReleaseMutex();
+ #endregion GroupMembersCachesMutex
+
+ GroupMembersCallbacks[group] = gmc;
+
+ GroupMembersRequestPacket request = new GroupMembersRequestPacket();
+
+ request.AgentData.AgentID = Client.Network.AgentID;
+ request.AgentData.SessionID = Client.Network.SessionID;
+ request.GroupData.GroupID = group;
+ request.GroupData.RequestID = requestID;
+
+ Client.Network.SendPacket(request);
+ }
+
+ public void BeginGetGroupRoles(LLUUID group, GroupRolesCallback grc)
+ {
+ LLUUID requestID = LLUUID.GenerateUUID();
+
+ #region GroupRolesCachesMutex
+ GroupRolesCachesMutex.WaitOne();
+ GroupRolesCaches[requestID] = new Dictionary();
+ GroupRolesCachesMutex.ReleaseMutex();
+ #endregion GroupRolesCachesMutex
+
+ GroupRolesCallbacks[group] = grc;
+
+ GroupRoleDataRequestPacket request = new GroupRoleDataRequestPacket();
+
+ request.AgentData.AgentID = Client.Network.AgentID;
+ request.AgentData.SessionID = Client.Network.SessionID;
+ request.GroupData.GroupID = group;
+ request.GroupData.RequestID = requestID;
+
+ Client.Network.SendPacket(request);
+ }
+
+ public void BeginGetGroupTitles(LLUUID group, GroupTitlesCallback gtc)
+ {
+ LLUUID requestID = LLUUID.GenerateUUID();
+
+ GroupTitlesCallbacks[group] = gtc;
+
+ GroupTitlesRequestPacket request = new GroupTitlesRequestPacket();
+
+ request.AgentData.AgentID = Client.Network.AgentID;
+ request.AgentData.SessionID = Client.Network.SessionID;
+ request.AgentData.GroupID = group;
+ request.AgentData.RequestID = requestID;
+
+ Client.Network.SendPacket(request);
+ }
+
private void GroupDataHandler(Packet packet, Simulator simulator)
{
- // FIXME: Add an additional list, such as MyGroups that will distinguish the groups we are
- // actually in versus the ones we are just collecting data on. Or should there be a better
- // way to temporarily collect data for transient requests?
- AgentGroupDataUpdatePacket update = (AgentGroupDataUpdatePacket)packet;
-
- #region GroupsMutex
- GroupsMutex.WaitOne();
-
- // Flush out the groups list
- Groups.Clear();
-
- foreach (AgentGroupDataUpdatePacket.GroupDataBlock block in update.GroupData)
+ if (OnCurrentGroups != null)
{
- Group group = new Group(block.GroupID);
+ AgentGroupDataUpdatePacket update = (AgentGroupDataUpdatePacket)packet;
- group.InsigniaID = block.GroupInsigniaID;
- group.Name = Helpers.FieldToString(block.GroupName);
- group.Powers = block.GroupPowers;
- group.Contribution = block.Contribution;
- group.AcceptNotices = block.AcceptNotices;
+ Dictionary currentGroups = new Dictionary();
- Groups[group.ID] = group;
+ foreach (AgentGroupDataUpdatePacket.GroupDataBlock block in update.GroupData)
+ {
+ Group group = new Group(block.GroupID);
+
+ group.InsigniaID = block.GroupInsigniaID;
+ group.Name = Helpers.FieldToString(block.GroupName);
+ group.Powers = block.GroupPowers;
+ group.Contribution = block.Contribution;
+ group.AcceptNotices = block.AcceptNotices;
+
+ currentGroups[block.GroupID] = group;
+ }
+
+ OnCurrentGroups(currentGroups);
}
+ }
- GroupsMutex.ReleaseMutex();
- #endregion GroupsMutex
+ private void GroupProfileHandler(Packet packet, Simulator simulator)
+ {
+ GroupProfileReplyPacket profile = (GroupProfileReplyPacket)packet;
- if (OnGroupsUpdated != null)
+ if (GroupProfileCallbacks.ContainsKey(profile.GroupData.GroupID))
{
- OnGroupsUpdated();
+ GroupProfile group = new GroupProfile();
+
+ group.AllowPublish = profile.GroupData.AllowPublish;
+ group.Charter = Helpers.FieldToString(profile.GroupData.Charter);
+ group.FounderID = profile.GroupData.FounderID;
+ group.GroupMembershipCount = profile.GroupData.GroupMembershipCount;
+ group.GroupRolesCount = profile.GroupData.GroupRolesCount;
+ group.InsigniaID = profile.GroupData.InsigniaID;
+ group.MaturePublish = profile.GroupData.MaturePublish;
+ group.MembershipFee = profile.GroupData.MembershipFee;
+ group.MemberTitle = Helpers.FieldToString(profile.GroupData.MemberTitle);
+ group.Money = profile.GroupData.Money;
+ group.Name = Helpers.FieldToString(profile.GroupData.Name);
+ group.OpenEnrollment = profile.GroupData.OpenEnrollment;
+ group.OwnerRole = profile.GroupData.OwnerRole;
+ group.Powers = profile.GroupData.PowersMask;
+ group.ShowInList = profile.GroupData.ShowInList;
+
+ GroupProfileCallbacks[profile.GroupData.GroupID](group);
}
}
private void GroupTitlesHandler(Packet packet, Simulator simulator)
{
- Group thisGroup;
GroupTitlesReplyPacket titles = (GroupTitlesReplyPacket)packet;
- #region GroupsMutex
- GroupsMutex.WaitOne();
+ Dictionary groupTitleCache = new Dictionary();
- // Attempt to locate the group that these titles belong to
- if (Groups.ContainsKey(titles.AgentData.GroupID))
+ foreach (GroupTitlesReplyPacket.GroupDataBlock block in titles.GroupData)
{
- thisGroup = Groups[titles.AgentData.GroupID];
- }
- else
- {
- // Avoid throwing this data away by creating a new group
- thisGroup = new Group(titles.AgentData.GroupID);
- thisGroup.TitlesRequestID = titles.AgentData.RequestID;
- Groups[titles.AgentData.GroupID] = thisGroup;
+ GroupTitle groupTitle = new GroupTitle();
+
+ groupTitle.Title = Helpers.FieldToString(block.Title);
+ groupTitle.Selected = block.Selected;
+
+ groupTitleCache[block.RoleID] = groupTitle;
}
- if (titles.AgentData.RequestID == thisGroup.TitlesRequestID)
- {
- foreach (GroupTitlesReplyPacket.GroupDataBlock block in titles.GroupData)
- {
- thisGroup.Titles[Helpers.FieldToString(block.Title)] = block.RoleID;
- // TODO: Do something with block.Selected
- }
- }
-
- GroupsMutex.ReleaseMutex();
- #endregion
- }
-
- private void GroupProfileHandler(Packet packet, Simulator simulator)
- {
- Group thisGroup;
- GroupProfileReplyPacket profile = (GroupProfileReplyPacket)packet;
-
- #region GroupsMutex
- GroupsMutex.WaitOne();
-
- // Attempt to locate the group that these titles belong to
- if (Groups.ContainsKey(profile.GroupData.GroupID))
- {
- thisGroup = Groups[profile.GroupData.GroupID];
- }
- else
- {
- thisGroup = new Group(profile.GroupData.GroupID);
- Groups[profile.GroupData.GroupID] = thisGroup;
- }
-
- thisGroup.AllowPublish = profile.GroupData.AllowPublish;
- thisGroup.Charter = Helpers.FieldToString(profile.GroupData.Charter);
- thisGroup.FounderID = profile.GroupData.FounderID;
- thisGroup.GroupMembershipCount = profile.GroupData.GroupMembershipCount;
- thisGroup.GroupRolesCount = profile.GroupData.GroupRolesCount;
- thisGroup.InsigniaID = profile.GroupData.InsigniaID;
- thisGroup.MaturePublish = profile.GroupData.MaturePublish;
- thisGroup.MembershipFee = profile.GroupData.MembershipFee;
- thisGroup.MemberTitle = Helpers.FieldToString(profile.GroupData.MemberTitle);
- thisGroup.Money = profile.GroupData.Money;
- thisGroup.Name = Helpers.FieldToString(profile.GroupData.Name);
- thisGroup.OpenEnrollment = profile.GroupData.OpenEnrollment;
- thisGroup.OwnerRole = profile.GroupData.OwnerRole;
- thisGroup.Powers = profile.GroupData.PowersMask;
- thisGroup.ShowInList = profile.GroupData.ShowInList;
-
- GroupsMutex.ReleaseMutex();
- #endregion
+ GroupTitlesCallbacks[titles.AgentData.GroupID](groupTitleCache);
}
private void GroupMembersHandler(Packet packet, Simulator simulator)
{
- Group thisGroup;
GroupMembersReplyPacket members = (GroupMembersReplyPacket)packet;
- #region GroupsMutex
- GroupsMutex.WaitOne();
+ #region GroupMembersCachesMutex
+ GroupMembersCachesMutex.WaitOne();
- if (Groups.ContainsKey(members.GroupData.GroupID))
+ // If nothing is registered to receive this RequestID drop the data
+ if (GroupMembersCaches.ContainsKey(members.GroupData.RequestID))
{
- thisGroup = Groups[members.GroupData.GroupID];
+ Dictionary groupMemberCache = GroupMembersCaches[members.GroupData.RequestID];
+
+ foreach (GroupMembersReplyPacket.MemberDataBlock block in members.MemberData)
+ {
+ GroupMember groupMember = new GroupMember(block.AgentID);
+
+ groupMember.Contribution = block.Contribution;
+ groupMember.IsOwner = block.IsOwner;
+ groupMember.OnlineStatus = Helpers.FieldToString(block.OnlineStatus);
+ groupMember.Powers = block.AgentPowers;
+ groupMember.Title = Helpers.FieldToString(block.Title);
+
+ groupMemberCache[block.AgentID] = groupMember;
+ }
+
+ // Release the mutex before the callback
+ GroupMembersCachesMutex.ReleaseMutex();
+
+ // Check if we've received all the group members that are showing up
+ if (groupMemberCache.Count >= members.GroupData.MemberCount)
+ {
+ GroupMembersCallbacks[members.GroupData.GroupID](groupMemberCache);
+ }
}
else
{
- thisGroup = new Group(members.GroupData.GroupID);
- Groups[members.GroupData.GroupID] = thisGroup;
+ GroupMembersCachesMutex.ReleaseMutex();
}
- if (members.GroupData.RequestID == thisGroup.MembersRequestID)
- {
- foreach (GroupMembersReplyPacket.MemberDataBlock block in members.MemberData)
- {
- GroupMember member = new GroupMember(block.AgentID);
-
- member.Contribution = block.Contribution;
- member.ID = block.AgentID;
- member.IsOwner = block.IsOwner;
- member.OnlineStatus = Helpers.FieldToString(block.OnlineStatus);
- member.Powers = block.AgentPowers;
- member.Title = Helpers.FieldToString(block.Title);
-
- thisGroup.Members[member.ID] = member;
- }
- }
-
- GroupsMutex.ReleaseMutex();
- #endregion
+ #endregion GroupMembersCachesMutex
}
private void GroupRoleDataHandler(Packet packet, Simulator simulator)
{
- Group thisGroup;
- GroupRole thisRole;
GroupRoleDataReplyPacket roles = (GroupRoleDataReplyPacket)packet;
-
- #region GroupsMutex
- GroupsMutex.WaitOne();
-
- if (Groups.ContainsKey(roles.GroupData.GroupID))
- {
- thisGroup = Groups[roles.GroupData.GroupID];
- }
- else
- {
- thisGroup = new Group(roles.GroupData.GroupID);
- Groups[roles.GroupData.GroupID] = thisGroup;
- }
-
- foreach (GroupRoleDataReplyPacket.RoleDataBlock block in roles.RoleData)
- {
- if (thisGroup.Roles.ContainsKey(block.RoleID))
- {
- thisRole = thisGroup.Roles[block.RoleID];
- }
- else
- {
- thisRole = new GroupRole(block.RoleID);
- thisGroup.Roles[block.RoleID] = thisRole;
- }
-
- thisRole.Description = Helpers.FieldToString(block.Description);
- thisRole.Name = Helpers.FieldToString(block.Name);
- thisRole.Powers = block.Powers;
- thisRole.Title = Helpers.FieldToString(block.Title);
- }
-
- GroupsMutex.ReleaseMutex();
- #endregion
}
private void GroupRoleMembersHandler(Packet packet, Simulator simulator)
{
- Group thisGroup;
- GroupRole thisRole;
- GroupMember thisMember;
GroupRoleMembersReplyPacket members = (GroupRoleMembersReplyPacket)packet;
-
- #region GroupsMutex
- GroupsMutex.WaitOne();
-
- if (Groups.ContainsKey(members.AgentData.GroupID))
- {
- thisGroup = Groups[members.AgentData.GroupID];
- }
- else
- {
- thisGroup = new Group(members.AgentData.GroupID);
- Groups[members.AgentData.GroupID] = thisGroup;
- }
-
- foreach (GroupRoleMembersReplyPacket.MemberDataBlock block in members.MemberData)
- {
- if (thisGroup.Roles.ContainsKey(block.RoleID))
- {
- thisRole = thisGroup.Roles[block.RoleID];
- }
- else
- {
- thisRole = new GroupRole(block.RoleID);
- thisGroup.Roles[block.RoleID] = thisRole;
- }
-
- if (thisGroup.Members.ContainsKey(block.MemberID))
- {
- thisMember = thisGroup.Members[block.MemberID];
- }
- else
- {
- thisMember = new GroupMember(block.MemberID);
- thisGroup.Members[block.MemberID] = thisMember;
- }
-
- // Add this member to this block if it doesn't already exist there
- if (!thisRole.Members.ContainsKey(block.MemberID))
- {
- thisRole.Members[block.MemberID] = thisMember;
- }
- }
-
- GroupsMutex.ReleaseMutex();
- #endregion
}
private void GroupActiveProposalItemHandler(Packet packet, Simulator simulator)
diff --git a/libsecondlife-cs/examples/groupmanager/frmGroupInfo.Designer.cs b/libsecondlife-cs/examples/groupmanager/frmGroupInfo.Designer.cs
index 3150c749..d30d5317 100644
--- a/libsecondlife-cs/examples/groupmanager/frmGroupInfo.Designer.cs
+++ b/libsecondlife-cs/examples/groupmanager/frmGroupInfo.Designer.cs
@@ -29,33 +29,265 @@ namespace groupmanager
private void InitializeComponent()
{
this.picInsignia = new System.Windows.Forms.PictureBox();
+ this.lblGroupName = new System.Windows.Forms.Label();
+ this.lblFoundedBy = new System.Windows.Forms.Label();
+ this.txtCharter = new System.Windows.Forms.TextBox();
+ this.label1 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.lstMembers = new System.Windows.Forms.ListView();
+ this.colName = new System.Windows.Forms.ColumnHeader();
+ this.colTitle = new System.Windows.Forms.ColumnHeader();
+ this.colLasLogin = new System.Windows.Forms.ColumnHeader();
+ this.label3 = new System.Windows.Forms.Label();
+ this.grpPreferences = new System.Windows.Forms.GroupBox();
+ this.chkShow = new System.Windows.Forms.CheckBox();
+ this.chkPublish = new System.Windows.Forms.CheckBox();
+ this.chkOpenEnrollment = new System.Windows.Forms.CheckBox();
+ this.chkFee = new System.Windows.Forms.CheckBox();
+ this.chkGroupNotices = new System.Windows.Forms.CheckBox();
+ this.numFee = new System.Windows.Forms.NumericUpDown();
+ this.chkMature = new System.Windows.Forms.CheckBox();
+ this.lblMemberTitle = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.picInsignia)).BeginInit();
+ this.grpPreferences.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.numFee)).BeginInit();
this.SuspendLayout();
//
// picInsignia
//
- this.picInsignia.Location = new System.Drawing.Point(12, 12);
+ this.picInsignia.Location = new System.Drawing.Point(12, 51);
this.picInsignia.Name = "picInsignia";
- this.picInsignia.Size = new System.Drawing.Size(134, 117);
+ this.picInsignia.Size = new System.Drawing.Size(150, 150);
this.picInsignia.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.picInsignia.TabIndex = 0;
this.picInsignia.TabStop = false;
//
+ // lblGroupName
+ //
+ this.lblGroupName.AutoSize = true;
+ this.lblGroupName.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.lblGroupName.Location = new System.Drawing.Point(12, 8);
+ this.lblGroupName.Name = "lblGroupName";
+ this.lblGroupName.Size = new System.Drawing.Size(99, 17);
+ this.lblGroupName.TabIndex = 1;
+ this.lblGroupName.Text = "Group Name";
+ //
+ // lblFoundedBy
+ //
+ this.lblFoundedBy.AutoSize = true;
+ this.lblFoundedBy.Location = new System.Drawing.Point(12, 31);
+ this.lblFoundedBy.Name = "lblFoundedBy";
+ this.lblFoundedBy.Size = new System.Drawing.Size(137, 13);
+ this.lblFoundedBy.TabIndex = 2;
+ this.lblFoundedBy.Text = "Founded by Group Founder";
+ //
+ // txtCharter
+ //
+ this.txtCharter.Location = new System.Drawing.Point(177, 51);
+ this.txtCharter.Multiline = true;
+ this.txtCharter.Name = "txtCharter";
+ this.txtCharter.Size = new System.Drawing.Size(316, 221);
+ this.txtCharter.TabIndex = 3;
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(420, 31);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(73, 13);
+ this.label1.TabIndex = 4;
+ this.label1.Text = "Group Charter";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(12, 280);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(143, 13);
+ this.label2.TabIndex = 5;
+ this.label2.Text = "Owners and Visible Members";
+ //
+ // lstMembers
+ //
+ this.lstMembers.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
+ this.colName,
+ this.colTitle,
+ this.colLasLogin});
+ this.lstMembers.Location = new System.Drawing.Point(15, 296);
+ this.lstMembers.Name = "lstMembers";
+ this.lstMembers.Size = new System.Drawing.Size(478, 126);
+ this.lstMembers.TabIndex = 6;
+ this.lstMembers.UseCompatibleStateImageBehavior = false;
+ this.lstMembers.View = System.Windows.Forms.View.Details;
+ //
+ // colName
+ //
+ this.colName.Text = "Member Name";
+ this.colName.Width = 194;
+ //
+ // colTitle
+ //
+ this.colTitle.Text = "Title";
+ this.colTitle.Width = 152;
+ //
+ // colLasLogin
+ //
+ this.colLasLogin.Text = "Last Login";
+ this.colLasLogin.Width = 121;
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(12, 205);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(75, 13);
+ this.label3.TabIndex = 7;
+ this.label3.Text = "Group Insignia";
+ //
+ // grpPreferences
+ //
+ this.grpPreferences.Controls.Add(this.lblMemberTitle);
+ this.grpPreferences.Controls.Add(this.chkMature);
+ this.grpPreferences.Controls.Add(this.numFee);
+ this.grpPreferences.Controls.Add(this.chkGroupNotices);
+ this.grpPreferences.Controls.Add(this.chkFee);
+ this.grpPreferences.Controls.Add(this.chkOpenEnrollment);
+ this.grpPreferences.Controls.Add(this.chkPublish);
+ this.grpPreferences.Controls.Add(this.chkShow);
+ this.grpPreferences.Location = new System.Drawing.Point(15, 428);
+ this.grpPreferences.Name = "grpPreferences";
+ this.grpPreferences.Size = new System.Drawing.Size(478, 122);
+ this.grpPreferences.TabIndex = 8;
+ this.grpPreferences.TabStop = false;
+ this.grpPreferences.Text = "Group Preferences";
+ //
+ // chkShow
+ //
+ this.chkShow.AutoSize = true;
+ this.chkShow.Location = new System.Drawing.Point(16, 19);
+ this.chkShow.Name = "chkShow";
+ this.chkShow.Size = new System.Drawing.Size(116, 17);
+ this.chkShow.TabIndex = 0;
+ this.chkShow.Text = "Show In Group List";
+ this.chkShow.UseVisualStyleBackColor = true;
+ //
+ // chkPublish
+ //
+ this.chkPublish.AutoSize = true;
+ this.chkPublish.Location = new System.Drawing.Point(16, 42);
+ this.chkPublish.Name = "chkPublish";
+ this.chkPublish.Size = new System.Drawing.Size(116, 17);
+ this.chkPublish.TabIndex = 1;
+ this.chkPublish.Text = "Publish on the web";
+ this.chkPublish.UseVisualStyleBackColor = true;
+ //
+ // chkOpenEnrollment
+ //
+ this.chkOpenEnrollment.AutoSize = true;
+ this.chkOpenEnrollment.Location = new System.Drawing.Point(16, 65);
+ this.chkOpenEnrollment.Name = "chkOpenEnrollment";
+ this.chkOpenEnrollment.Size = new System.Drawing.Size(104, 17);
+ this.chkOpenEnrollment.TabIndex = 2;
+ this.chkOpenEnrollment.Text = "Open Enrollment";
+ this.chkOpenEnrollment.UseVisualStyleBackColor = true;
+ //
+ // chkFee
+ //
+ this.chkFee.AutoSize = true;
+ this.chkFee.Location = new System.Drawing.Point(36, 88);
+ this.chkFee.Name = "chkFee";
+ this.chkFee.Size = new System.Drawing.Size(114, 17);
+ this.chkFee.TabIndex = 3;
+ this.chkFee.Text = "Enrollment Fee: L$";
+ this.chkFee.UseVisualStyleBackColor = true;
+ //
+ // chkGroupNotices
+ //
+ this.chkGroupNotices.AutoSize = true;
+ this.chkGroupNotices.Location = new System.Drawing.Point(312, 87);
+ this.chkGroupNotices.Name = "chkGroupNotices";
+ this.chkGroupNotices.Size = new System.Drawing.Size(137, 17);
+ this.chkGroupNotices.TabIndex = 4;
+ this.chkGroupNotices.Text = "Receive Group Notices";
+ this.chkGroupNotices.UseVisualStyleBackColor = true;
+ //
+ // numFee
+ //
+ this.numFee.Location = new System.Drawing.Point(162, 87);
+ this.numFee.Name = "numFee";
+ this.numFee.Size = new System.Drawing.Size(144, 20);
+ this.numFee.TabIndex = 5;
+ //
+ // chkMature
+ //
+ this.chkMature.AutoSize = true;
+ this.chkMature.Location = new System.Drawing.Point(162, 19);
+ this.chkMature.Name = "chkMature";
+ this.chkMature.Size = new System.Drawing.Size(95, 17);
+ this.chkMature.TabIndex = 6;
+ this.chkMature.Text = "Mature publish";
+ this.chkMature.UseVisualStyleBackColor = true;
+ //
+ // lblMemberTitle
+ //
+ this.lblMemberTitle.AutoSize = true;
+ this.lblMemberTitle.Location = new System.Drawing.Point(162, 43);
+ this.lblMemberTitle.Name = "lblMemberTitle";
+ this.lblMemberTitle.Size = new System.Drawing.Size(68, 13);
+ this.lblMemberTitle.TabIndex = 7;
+ this.lblMemberTitle.Text = "Member Title";
+ //
// frmGroupInfo
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(429, 322);
+ this.ClientSize = new System.Drawing.Size(505, 562);
+ this.Controls.Add(this.grpPreferences);
+ this.Controls.Add(this.label3);
+ this.Controls.Add(this.lstMembers);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.txtCharter);
+ this.Controls.Add(this.lblFoundedBy);
+ this.Controls.Add(this.lblGroupName);
this.Controls.Add(this.picInsignia);
+ this.MaximizeBox = false;
+ this.MinimumSize = new System.Drawing.Size(513, 548);
this.Name = "frmGroupInfo";
- this.Text = "Group Info";
+ this.ShowInTaskbar = false;
+ this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
+ this.Text = "Group Information";
+ this.Load += new System.EventHandler(this.frmGroupInfo_Load);
((System.ComponentModel.ISupportInitialize)(this.picInsignia)).EndInit();
+ this.grpPreferences.ResumeLayout(false);
+ this.grpPreferences.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.numFee)).EndInit();
this.ResumeLayout(false);
+ this.PerformLayout();
}
#endregion
private System.Windows.Forms.PictureBox picInsignia;
+ private System.Windows.Forms.Label lblGroupName;
+ private System.Windows.Forms.Label lblFoundedBy;
+ private System.Windows.Forms.TextBox txtCharter;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.ListView lstMembers;
+ private System.Windows.Forms.ColumnHeader colName;
+ private System.Windows.Forms.ColumnHeader colTitle;
+ private System.Windows.Forms.ColumnHeader colLasLogin;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.GroupBox grpPreferences;
+ private System.Windows.Forms.CheckBox chkPublish;
+ private System.Windows.Forms.CheckBox chkShow;
+ private System.Windows.Forms.NumericUpDown numFee;
+ private System.Windows.Forms.CheckBox chkGroupNotices;
+ private System.Windows.Forms.CheckBox chkFee;
+ private System.Windows.Forms.CheckBox chkOpenEnrollment;
+ private System.Windows.Forms.CheckBox chkMature;
+ private System.Windows.Forms.Label lblMemberTitle;
}
}
\ No newline at end of file
diff --git a/libsecondlife-cs/examples/groupmanager/frmGroupInfo.cs b/libsecondlife-cs/examples/groupmanager/frmGroupInfo.cs
index 732b0e77..7dd4d036 100644
--- a/libsecondlife-cs/examples/groupmanager/frmGroupInfo.cs
+++ b/libsecondlife-cs/examples/groupmanager/frmGroupInfo.cs
@@ -15,37 +15,94 @@ namespace groupmanager
{
Group Group;
SecondLife Client;
+ GroupProfile Profile;
+ Dictionary Members;
+ Dictionary Titles;
public frmGroupInfo(Group group, SecondLife client)
{
Group = group;
Client = client;
+ InitializeComponent();
+ }
+
+ private void frmGroupInfo_Load(object sender, EventArgs e)
+ {
+ Client.Groups.BeginGetGroupProfile(Group.ID,
+ new GroupManager.GroupProfileCallback(GroupProfileHandler));
+
+ Client.Groups.BeginGetGroupMembers(Group.ID,
+ new GroupManager.GroupMembersCallback(GroupMembersHandler));
+
+ Client.Groups.BeginGetGroupTitles(Group.ID,
+ new GroupManager.GroupTitlesCallback(GroupTitlesHandler));
+ }
+
+ private void GroupProfileHandler(GroupProfile profile)
+ {
+ Profile = profile;
+
+ Invoke(new MethodInvoker(UpdateProfile));
+
+ // Waterdrop: new LLUUID("c77a1c21-e604-7d2c-2c89-5539ce853466")
ImageManager im = new ImageManager(Client);
- byte[] j2cdata = im.RequestImage(new LLUUID("c77a1c21-e604-7d2c-2c89-5539ce853466")); //group.InsigniaID);
-
- BytesToFile(j2cdata, "output.j2c");
-
+ byte[] j2cdata = im.RequestImage(Group.InsigniaID);
+ //
JasperWrapper.jas_init();
- byte[] imagedata = JasperWrapper.jasper_decode_j2c_to_tga(j2cdata);
-
- BytesToFile(imagedata, "output.tga");
-
+ byte[] imagedata = JasperWrapper.jasper_decode_j2c_to_tiff(j2cdata);
+ //
MemoryStream imageStream = new MemoryStream(imagedata, false);
Image image = Image.FromStream(imageStream, false, false);
-
- InitializeComponent();
-
+ //
picInsignia.Image = image;
}
- public void BytesToFile(byte[] bytes, string filename)
+ private void UpdateProfile()
{
- FileStream filestream = new FileStream(filename, FileMode.Create);
- BinaryWriter writer = new BinaryWriter(filestream);
- writer.Write(bytes);
- writer.Close();
- filestream.Close();
+ lblGroupName.Text = Profile.Name;
+ lblFoundedBy.Text = "Founded by " + Profile.FounderID.ToStringHyphenated();
+ txtCharter.Text = Profile.Charter;
+ chkShow.Checked = Profile.ShowInList;
+ chkPublish.Checked = Profile.AllowPublish;
+ chkOpenEnrollment.Checked = Profile.OpenEnrollment;
+ chkFee.Checked = (Profile.MembershipFee != 0);
+ numFee.Value = Profile.MembershipFee;
+ chkMature.Checked = Profile.MaturePublish;
+ lblMemberTitle.Text = Profile.MemberTitle;
}
+
+ private void GroupMembersHandler(Dictionary members)
+ {
+ Members = members;
+
+ Invoke(new MethodInvoker(UpdateMembers));
+ }
+
+ private void UpdateMembers()
+ {
+ ;
+ }
+
+ private void GroupTitlesHandler(Dictionary titles)
+ {
+ Titles = titles;
+
+ Invoke(new MethodInvoker(UpdateTitles));
+ }
+
+ private void UpdateTitles()
+ {
+ ;
+ }
+
+ //private void BytesToFile(byte[] bytes, string filename)
+ //{
+ // FileStream filestream = new FileStream(filename, FileMode.Create);
+ // BinaryWriter writer = new BinaryWriter(filestream);
+ // writer.Write(bytes);
+ // writer.Close();
+ // filestream.Close();
+ //}
}
}
diff --git a/libsecondlife-cs/examples/groupmanager/frmGroupManager.Designer.cs b/libsecondlife-cs/examples/groupmanager/frmGroupManager.Designer.cs
index 2a446910..727a1592 100644
--- a/libsecondlife-cs/examples/groupmanager/frmGroupManager.Designer.cs
+++ b/libsecondlife-cs/examples/groupmanager/frmGroupManager.Designer.cs
@@ -29,6 +29,10 @@ namespace groupmanager
private void InitializeComponent()
{
this.groupBox = new System.Windows.Forms.GroupBox();
+ this.cmdInfo = new System.Windows.Forms.Button();
+ this.cmdActivate = new System.Windows.Forms.Button();
+ this.cmdCreate = new System.Windows.Forms.Button();
+ this.cmdLeave = new System.Windows.Forms.Button();
this.lstGroups = new System.Windows.Forms.ListBox();
this.grpLogin = new System.Windows.Forms.GroupBox();
this.label3 = new System.Windows.Forms.Label();
@@ -38,10 +42,6 @@ namespace groupmanager
this.txtLastName = new System.Windows.Forms.TextBox();
this.cmdConnect = new System.Windows.Forms.Button();
this.txtFirstName = new System.Windows.Forms.TextBox();
- this.cmdLeave = new System.Windows.Forms.Button();
- this.cmdCreate = new System.Windows.Forms.Button();
- this.cmdActivate = new System.Windows.Forms.Button();
- this.cmdInfo = new System.Windows.Forms.Button();
this.groupBox.SuspendLayout();
this.grpLogin.SuspendLayout();
this.SuspendLayout();
@@ -61,6 +61,46 @@ namespace groupmanager
this.groupBox.TabStop = false;
this.groupBox.Text = "Groups";
//
+ // cmdInfo
+ //
+ this.cmdInfo.Enabled = false;
+ this.cmdInfo.Location = new System.Drawing.Point(216, 174);
+ this.cmdInfo.Name = "cmdInfo";
+ this.cmdInfo.Size = new System.Drawing.Size(90, 23);
+ this.cmdInfo.TabIndex = 10;
+ this.cmdInfo.Text = "Info";
+ this.cmdInfo.UseVisualStyleBackColor = true;
+ this.cmdInfo.Click += new System.EventHandler(this.cmdInfo_Click);
+ //
+ // cmdActivate
+ //
+ this.cmdActivate.Enabled = false;
+ this.cmdActivate.Location = new System.Drawing.Point(116, 174);
+ this.cmdActivate.Name = "cmdActivate";
+ this.cmdActivate.Size = new System.Drawing.Size(90, 23);
+ this.cmdActivate.TabIndex = 9;
+ this.cmdActivate.Text = "Activate";
+ this.cmdActivate.UseVisualStyleBackColor = true;
+ //
+ // cmdCreate
+ //
+ this.cmdCreate.Location = new System.Drawing.Point(19, 174);
+ this.cmdCreate.Name = "cmdCreate";
+ this.cmdCreate.Size = new System.Drawing.Size(90, 23);
+ this.cmdCreate.TabIndex = 8;
+ this.cmdCreate.Text = "Create";
+ this.cmdCreate.UseVisualStyleBackColor = true;
+ //
+ // cmdLeave
+ //
+ this.cmdLeave.Enabled = false;
+ this.cmdLeave.Location = new System.Drawing.Point(313, 174);
+ this.cmdLeave.Name = "cmdLeave";
+ this.cmdLeave.Size = new System.Drawing.Size(90, 23);
+ this.cmdLeave.TabIndex = 7;
+ this.cmdLeave.Text = "Leave";
+ this.cmdLeave.UseVisualStyleBackColor = true;
+ //
// lstGroups
//
this.lstGroups.FormattingEnabled = true;
@@ -140,46 +180,6 @@ namespace groupmanager
this.txtFirstName.Size = new System.Drawing.Size(120, 20);
this.txtFirstName.TabIndex = 0;
//
- // cmdLeave
- //
- this.cmdLeave.Enabled = false;
- this.cmdLeave.Location = new System.Drawing.Point(313, 174);
- this.cmdLeave.Name = "cmdLeave";
- this.cmdLeave.Size = new System.Drawing.Size(90, 23);
- this.cmdLeave.TabIndex = 7;
- this.cmdLeave.Text = "Leave";
- this.cmdLeave.UseVisualStyleBackColor = true;
- //
- // cmdCreate
- //
- this.cmdCreate.Location = new System.Drawing.Point(19, 174);
- this.cmdCreate.Name = "cmdCreate";
- this.cmdCreate.Size = new System.Drawing.Size(90, 23);
- this.cmdCreate.TabIndex = 8;
- this.cmdCreate.Text = "Create";
- this.cmdCreate.UseVisualStyleBackColor = true;
- //
- // cmdActivate
- //
- this.cmdActivate.Enabled = false;
- this.cmdActivate.Location = new System.Drawing.Point(116, 174);
- this.cmdActivate.Name = "cmdActivate";
- this.cmdActivate.Size = new System.Drawing.Size(90, 23);
- this.cmdActivate.TabIndex = 9;
- this.cmdActivate.Text = "Activate";
- this.cmdActivate.UseVisualStyleBackColor = true;
- //
- // cmdInfo
- //
- this.cmdInfo.Enabled = false;
- this.cmdInfo.Location = new System.Drawing.Point(216, 174);
- this.cmdInfo.Name = "cmdInfo";
- this.cmdInfo.Size = new System.Drawing.Size(90, 23);
- this.cmdInfo.TabIndex = 10;
- this.cmdInfo.Text = "Info";
- this.cmdInfo.UseVisualStyleBackColor = true;
- this.cmdInfo.Click += new System.EventHandler(this.cmdInfo_Click);
- //
// frmGroupManager
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -191,8 +191,8 @@ namespace groupmanager
this.MaximumSize = new System.Drawing.Size(453, 378);
this.MinimumSize = new System.Drawing.Size(453, 378);
this.Name = "frmGroupManager";
+ this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.Text = "Group Manager";
- //this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmGroupManager_FormClosing);
this.groupBox.ResumeLayout(false);
this.grpLogin.ResumeLayout(false);
this.grpLogin.PerformLayout();
diff --git a/libsecondlife-cs/examples/groupmanager/frmGroupManager.cs b/libsecondlife-cs/examples/groupmanager/frmGroupManager.cs
index 1f857121..0535cbe1 100644
--- a/libsecondlife-cs/examples/groupmanager/frmGroupManager.cs
+++ b/libsecondlife-cs/examples/groupmanager/frmGroupManager.cs
@@ -12,28 +12,33 @@ namespace groupmanager
{
public partial class frmGroupManager : Form
{
- SecondLife client;
+ SecondLife Client;
+ Dictionary Groups;
public frmGroupManager()
{
- client = new SecondLife();
- client.Groups.OnGroupsUpdated += new GroupManager.GroupsUpdatedCallback(GroupsUpdatedHandler);
-
+ Client = new SecondLife();
+
InitializeComponent();
}
- void GroupsUpdatedHandler()
+ void GroupsUpdatedHandler(Dictionary groups)
{
+ Groups = groups;
+
Invoke(new MethodInvoker(UpdateGroups));
}
void UpdateGroups()
{
- lstGroups.Items.Clear();
-
- foreach (Group group in client.Groups.Groups.Values)
+ lock (lstGroups)
{
- lstGroups.Items.Add(group);
+ lstGroups.Items.Clear();
+
+ foreach (Group group in Groups.Values)
+ {
+ lstGroups.Items.Add(group);
+ }
}
}
@@ -58,13 +63,15 @@ namespace groupmanager
txtLastName.Text, txtPassword.Text, "00:00:00:00:00:00", "last",
"Win", "0", "groupmanager", "jhurliman@wsu.edu");
- if (client.Network.Login(loginParams))
+ if (Client.Network.Login(loginParams))
{
groupBox.Enabled = true;
+
+ Client.Groups.BeginGetCurrentGroups(new GroupManager.CurrentGroupsCallback(GroupsUpdatedHandler));
}
else
{
- MessageBox.Show(this, "Error logging in: " + client.Network.LoginError);
+ MessageBox.Show(this, "Error logging in: " + Client.Network.LoginError);
cmdConnect.Text = "Connect";
txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true;
groupBox.Enabled = false;
@@ -73,7 +80,7 @@ namespace groupmanager
}
else
{
- client.Network.Logout();
+ Client.Network.Logout();
cmdConnect.Text = "Connect";
txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true;
groupBox.Enabled = false;
@@ -99,16 +106,16 @@ namespace groupmanager
{
Group group = (Group)lstGroups.Items[lstGroups.SelectedIndex];
- frmGroupInfo frm = new frmGroupInfo(group, client);
+ frmGroupInfo frm = new frmGroupInfo(group, Client);
frm.ShowDialog();
}
}
private void frmGroupManager_FormClosing(object sender, FormClosingEventArgs e)
{
- if (client.Network.Connected)
+ if (Client.Network.Connected)
{
- client.Network.Logout();
+ Client.Network.Logout();
}
}
}