public static user_info[] TestBuddyList() { user_info[] buddylist = new user_info[12]; String pictureURL = "http://192.168.3.33/avatar.bmp"; //String pictureURL = "C:\\Users\\Paul\\Pictures\\RTP packets fail.png"; buddylist[0].UserID = 501; buddylist[0].Name = "1 Tim"; buddylist[0].Location = "1 Next to me"; buddylist[0].Status = user_status.Joinable; buddylist[0].ConferenceID = 999670; buddylist[0].ConferencePIN = 642250; buddylist[0].Avatar = pictureURL; buddylist[0].Tagline = "1 Tagline"; buddylist[1].UserID = 502; buddylist[1].Name = "2 Tim"; buddylist[1].Location = "2 Next to me"; buddylist[1].Status = user_status.Offline; buddylist[1].ConferenceID = 999671; buddylist[1].ConferencePIN = 642251; buddylist[1].Avatar = pictureURL; buddylist[1].Tagline = "2 Tagline"; buddylist[2].UserID = 503; buddylist[2].Name = "3 Tim"; buddylist[2].Location = "3 Next to me"; buddylist[2].Status = user_status.NotJoinable; buddylist[2].ConferenceID = 999672; buddylist[2].ConferencePIN = 642252; buddylist[2].Avatar = pictureURL; buddylist[2].Tagline = "3 Tagline"; buddylist[3].UserID = 504; buddylist[3].Name = "4 Tim"; buddylist[3].Location = "4 Next to me"; buddylist[3].Status = user_status.Joinable; buddylist[3].ConferenceID = 999673; buddylist[3].ConferencePIN = 642253; buddylist[3].Avatar = pictureURL; buddylist[3].Tagline = "4 Tagline"; buddylist[4].UserID = 505; buddylist[4].Name = "5 Tim"; buddylist[4].Location = "5 Next to me"; buddylist[4].Status = user_status.NotJoinable; buddylist[4].ConferenceID = 999674; buddylist[4].ConferencePIN = 642254; buddylist[4].Avatar = pictureURL; buddylist[4].Tagline = "5 Tagline"; buddylist[5].UserID = 506; buddylist[5].Name = "6 Tim"; buddylist[5].Location = "6 Next to me"; buddylist[5].Status = user_status.Offline; buddylist[5].ConferenceID = 999675; buddylist[5].ConferencePIN = 642255; buddylist[5].Avatar = pictureURL; buddylist[5].Tagline = "6 Tagline"; buddylist[6].UserID = 507; buddylist[6].Name = "7 Tim"; buddylist[6].Location = "7 Next to me"; buddylist[6].Status = user_status.Joinable; buddylist[6].ConferenceID = 999676; buddylist[6].ConferencePIN = 642256; buddylist[6].Avatar = pictureURL; buddylist[6].Tagline = "7 Tagline"; buddylist[7].UserID = 508; buddylist[7].Name = "8 Tim"; buddylist[7].Location = "8 Next to me"; buddylist[7].Status = user_status.Joinable; buddylist[7].ConferenceID = 999677; buddylist[7].ConferencePIN = 642257; buddylist[7].Avatar = pictureURL; buddylist[7].Tagline = "8 Tagline"; buddylist[8].UserID = 509; buddylist[8].Name = "9 Tim"; buddylist[8].Location = "9 Next to me"; buddylist[8].Status = user_status.Joinable; buddylist[8].ConferenceID = 999678; buddylist[8].ConferencePIN = 642258; buddylist[8].Avatar = pictureURL; buddylist[8].Tagline = "9 Tagline"; buddylist[9].UserID = 510; buddylist[9].Name = "10 Tim"; buddylist[9].Location = "10 Next to me"; buddylist[9].Status = user_status.Joinable; buddylist[9].ConferenceID = 999679; buddylist[9].ConferencePIN = 642259; buddylist[9].Avatar = pictureURL; buddylist[9].Tagline = "10 Tagline"; buddylist[10].UserID = 511; buddylist[10].Name = "11 Tim"; buddylist[10].Location = "11 Next to me"; buddylist[10].Status = user_status.Joinable; buddylist[10].ConferenceID = 999670; buddylist[10].ConferencePIN = 642250; buddylist[10].Avatar = pictureURL; buddylist[10].Tagline = "11 Tagline"; buddylist[11].UserID = 512; buddylist[11].Name = "12 Tim"; buddylist[11].Location = "12 Next to me"; buddylist[11].Status = user_status.Joinable; buddylist[11].ConferenceID = 999671; buddylist[11].ConferencePIN = 642251; buddylist[11].Avatar = pictureURL; buddylist[11].Tagline = "12 Tagline"; return buddylist; }
//get user info for given id public static user_info svrUserInfo(Int32 user) { String XMLloc = ServerFunctionHelper.Post("http://" + hostname + "/stb_scripts/get_user_info.php", "user_id=" + user); XmlTextReader reader = new XmlTextReader(new StringReader(XMLloc)); user_info UserInfo = new user_info(); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: // The node is an Element if (reader.Depth == 1) { switch (reader.Name) { case "UserID": UserInfo.UserID = reader.ReadElementContentAsInt(); break; case "Name": UserInfo.Name = reader.ReadElementContentAsString(); break; case "Location": UserInfo.Location = reader.ReadElementContentAsString(); break; case "Status": UserInfo.Status = (user_status)reader.ReadElementContentAsInt(); break; case "Avatar": UserInfo.Avatar = reader.ReadElementContentAsString(); break; case "Tagline": UserInfo.Tagline = reader.ReadElementContentAsString(); break; } } break; } } return UserInfo; }
private Boolean compareBuddyLists(user_info[] previous, user_info[] current) { if (previous.Length != current.Length) { return false; } else { for (Int32 i = 0; i < previous.Length; i++) { if (previous[i].Status != current[i].Status) { return false; } } } return true; }
// get the buddy list from the server, return an array of user_infos public static user_info[] svrBuddyList(Int32 you) { String XMLloc = ServerFunctionHelper.Post("http://" + hostname + "/stb_scripts/get_buddylist.php", "user_id=" + you); Int32 i = 0; Int32 NoOfBuddies = 0; //Counts the total number of buddies in the xml file //*************************************************** XmlTextReader Counter = new XmlTextReader(new StringReader(XMLloc)); while (Counter.Read()) { switch (Counter.NodeType) { case XmlNodeType.Element: // The node is an Element if (Counter.Name == "Buddy") { NoOfBuddies++; } break; } } Counter.Close(); //*************************************************** XmlTextReader reader = new XmlTextReader(new StringReader(XMLloc)); user_info[] Buddies = new user_info[NoOfBuddies]; while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: // The node is an Element if (reader.Depth == 2) { switch (reader.Name) { case "UserID": i++; Buddies[i - 1].UserID = reader.ReadElementContentAsInt(); break; case "ConferenceID": Buddies[i - 1].ConferenceID = reader.ReadElementContentAsInt(); break; case "ConferencePIN": Buddies[i - 1].ConferencePIN = reader.ReadElementContentAsInt(); break; case "Status": Buddies[i - 1].Status = (user_status)reader.ReadElementContentAsInt(); break; case "Name": Buddies[i - 1].Name = reader.ReadElementContentAsString(); break; case "Location": Buddies[i - 1].Location = reader.ReadElementContentAsString(); break; case "Avatar": Buddies[i - 1].Avatar = reader.ReadElementContentAsString(); break; case "Tagline": Buddies[i - 1].Tagline = reader.ReadElementContentAsString(); break; } } break; } } return Buddies; }
void listRefreshTimer_Tick(object sender, EventArgs e) { user_info[] tempbuddylist = new user_info[100]; conf_info[] tempfavlist = new conf_info[100]; tempbuddylist = Data.constants.buddylist; tempfavlist = Data.constants.favlist; Int32 LastBuddyIndex = -1, LastFavIndex = -1; if (LstJoinBuddy.Focused) { LastBuddyIndex = LstJoinBuddy.FocusedItem.Index; } if (LstJoinFav.Focused) { LastFavIndex = LstJoinFav.FocusedItem.Index; } updateServerLists(); if (!compareBuddyLists(tempbuddylist, Data.constants.buddylist)) { LstJoinBuddy.Items.Clear(); AvatarList.Images.Clear(); AvatarList.Images.Add(System.Drawing.Image.FromFile("Images//locked.jpg")); PopulateBuddyListView(); } if (!compareFavLists(tempfavlist, Data.constants.favlist)) { LstJoinFav.Items.Clear(); FirstJoinFav = true; PopulateFavListView(); } if (LastBuddyIndex != -1) { LstJoinBuddy.Focus(); LstJoinBuddy.Items[LastBuddyIndex].Selected = true; LstJoinBuddy.Items[LastBuddyIndex].Focused = true; } else if (LastFavIndex != -1) { LstJoinFav.Focus(); LstJoinFav.Items[LastFavIndex].Selected = true; LstJoinFav.Items[LastFavIndex].Focused = true; } }