Пример #1
0
 protected internal BuddyInfo[] SortBuddyList()
 {
     BuddyInfo[] buddies = new BuddyInfo[this.Count];
     this.List.CopyTo(buddies, 0);
     Array.Sort(buddies, new BuddyGroupComparer());
     return(buddies);
 }
Пример #2
0
		/// <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);
		}
Пример #3
0
 /// <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);
 }
Пример #4
0
        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));
                }
            }
        }
Пример #5
0
 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);
     }
 }
Пример #6
0
 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);
     }
 }
Пример #7
0
		/// <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;
			}
		}
Пример #8
0
        /// <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);
            }
        }
Пример #9
0
 /// <summary>
 /// Whether the collection contains a buddy.
 /// </summary>
 public bool Contains(BuddyInfo buddyInfo)
 {
     return(lookUp.Contains(buddyInfo.ScreenName.ToLower()));
 }
Пример #10
0
		/// <summary>
		/// Insert a buddy into the collection.
		/// </summary>
		public void Insert(int index, BuddyInfo value) {
			List.Insert( index, value);
		}
Пример #11
0
 /// <summary>
 /// Get the index of buddy from the collection.
 /// </summary>
 public int IndexOf(BuddyInfo value)
 {
     return(List.IndexOf(value));
 }
Пример #12
0
 /// <summary>
 /// Insert a buddy into the collection.
 /// </summary>
 public void Insert(int index, BuddyInfo value)
 {
     List.Insert(index, value);
 }
Пример #13
0
		/// <summary>
		/// Whether the collection contains a buddy.
		/// </summary>
		public bool Contains(BuddyInfo buddyInfo){
			return lookUp.Contains(buddyInfo.ScreenName.ToLower());
		}
Пример #14
0
		protected internal BuddyInfo[] SortBuddyList(){
			BuddyInfo[] buddies = new BuddyInfo[this.Count];
			this.List.CopyTo(buddies,0);
			Array.Sort(buddies, new BuddyGroupComparer());
			return buddies;
		}
Пример #15
0
		/// <summary>
		/// Get the index of buddy from the collection.
		/// </summary>
		public int IndexOf(BuddyInfo value) {
			return List.IndexOf(value);
		}
Пример #16
0
 public BuddyUpdateEventArgs(BuddyInfo buddyInfo)
 {
     this.buddyInfo = buddyInfo;
 }
Пример #17
0
		public BuddyUpdateEventArgs(BuddyInfo buddyInfo) {
			this.buddyInfo = buddyInfo;
		}
Пример #18
0
		/// <summary>
		/// Copy the buddies to an array.
		/// </summary>
		public void CopyTo(BuddyInfo[] array, int index) {
			List.CopyTo(array, index);
		}