protected internal BuddyInfo[] SortBuddyList() { BuddyInfo[] buddies = new BuddyInfo[this.Count]; this.List.CopyTo(buddies, 0); Array.Sort(buddies, new BuddyGroupComparer()); return(buddies); }
/// <summary> /// Remove a Buddy to the collection. /// </summary> public void Remove(BuddyInfo buddyInfo) { if(tocClient.Connected){ tocClient.RemoveBuddy(buddyInfo.ScreenName); } lookUp.Remove(buddyInfo.screenName.ToLower()); List.Remove(buddyInfo); }
/// <summary> /// Remove a Buddy to the collection. /// </summary> public void Remove(BuddyInfo buddyInfo) { if (tocClient.Connected) { tocClient.RemoveBuddy(buddyInfo.ScreenName); } lookUp.Remove(buddyInfo.screenName.ToLower()); List.Remove(buddyInfo); }
private void HandleUpdate(String flap) { StringTokenizer stk = new StringTokenizer(flap, ':'); string screenName = stk.ReadToken(); BuddyInfo buddy = Buddies[screenName]; if (buddy != null) { buddy.screenName = screenName; buddy.online = stk.ReadToken() == "T"; buddy.evilAmount = int.Parse(stk.ReadToken()); long epochDate = long.Parse(stk.ReadToken()); buddy.signOnTime = new DateTime(1970, 1, 1).AddSeconds(epochDate); int idleMinutes = int.Parse(stk.ReadToken()); buddy.idleTime = new TimeSpan(0, idleMinutes, 0); buddy.isOnAol = stk.ReadChar() == 'A'; switch (stk.ReadChar()) { case 'A': buddy.userClass = BuddyUserClass.Admin; break; case 'U': buddy.userClass = BuddyUserClass.Unconfirmed; break; default: buddy.userClass = BuddyUserClass.Normal; break; } if (stk.HasMoreTokens) { buddy.isAvailable = stk.ReadChar() != 'U'; } else { buddy.isAvailable = true; } if (BuddyUpdate != null) { BuddyUpdate(this, new BuddyUpdateEventArgs(buddy)); } } }
internal void AddBuddy(string screenName) { if (protocol == ProtocolVersion.TOCv2) { BuddyInfo b = Buddies[screenName]; if (b == null) { throw new TocException("Buddy not in BuddyCollection."); } SendFlap(FrameType.Data, "toc2_new_buddies {g:" + b.Group + "\nb:" + screenName + "}"); } else { SendFlap(FrameType.Data, "toc_add_buddy " + screenName); } }
internal void RemoveBuddy(string screenName) { if (protocol == ProtocolVersion.TOCv2) { BuddyInfo b = Buddies[screenName]; if (b == null) { throw new TocException("Buddy not in BuddyCollection."); } SendFlap(FrameType.Data, "toc2_remove_buddy " + screenName + " " + b.Group); } else { SendFlap(FrameType.Data, "toc_remove_buddy " + screenName); } }
/// <summary> /// Add a Buddy to the collection. /// </summary> /// <returns>Index of Buddy. Returns -1 if Buddy is already in collection.</returns> public int Add(BuddyInfo buddyInfo) { string key = buddyInfo.ScreenName.ToLower(); if(lookUp.ContainsKey(key)){ return -1; } else { lookUp.Add(key, buddyInfo); int index = List.Add(buddyInfo); if(tocClient.Connected){ tocClient.AddBuddy(buddyInfo.ScreenName); } return index; } }
/// <summary> /// Add a Buddy to the collection. /// </summary> /// <returns>Index of Buddy. Returns -1 if Buddy is already in collection.</returns> public int Add(BuddyInfo buddyInfo) { string key = buddyInfo.ScreenName.ToLower(); if (lookUp.ContainsKey(key)) { return(-1); } else { lookUp.Add(key, buddyInfo); int index = List.Add(buddyInfo); if (tocClient.Connected) { tocClient.AddBuddy(buddyInfo.ScreenName); } return(index); } }
/// <summary> /// Whether the collection contains a buddy. /// </summary> public bool Contains(BuddyInfo buddyInfo) { return(lookUp.Contains(buddyInfo.ScreenName.ToLower())); }
/// <summary> /// Insert a buddy into the collection. /// </summary> public void Insert(int index, BuddyInfo value) { List.Insert( index, value); }
/// <summary> /// Get the index of buddy from the collection. /// </summary> public int IndexOf(BuddyInfo value) { return(List.IndexOf(value)); }
/// <summary> /// Insert a buddy into the collection. /// </summary> public void Insert(int index, BuddyInfo value) { List.Insert(index, value); }
/// <summary> /// Whether the collection contains a buddy. /// </summary> public bool Contains(BuddyInfo buddyInfo){ return lookUp.Contains(buddyInfo.ScreenName.ToLower()); }
protected internal BuddyInfo[] SortBuddyList(){ BuddyInfo[] buddies = new BuddyInfo[this.Count]; this.List.CopyTo(buddies,0); Array.Sort(buddies, new BuddyGroupComparer()); return buddies; }
/// <summary> /// Get the index of buddy from the collection. /// </summary> public int IndexOf(BuddyInfo value) { return List.IndexOf(value); }
public BuddyUpdateEventArgs(BuddyInfo buddyInfo) { this.buddyInfo = buddyInfo; }
/// <summary> /// Copy the buddies to an array. /// </summary> public void CopyTo(BuddyInfo[] array, int index) { List.CopyTo(array, index); }