예제 #1
0
			public ContactTreeNode(Contact contact)
			{
				this.Contact = contact;
			}
예제 #2
0
		private void onIqStanzaReceived(IQStanza s)
		{
			switch(s.Type)
			{
				case "get":
					// TODO
					break;
				case "set":
					if(s.Query != null && s.Query.NamespaceURI == "jabber:iq:roster")
						session.SendStanza(StanzaFactory.GetRosterStanza(session.JabberID));
					break;
				case "error":
					// TODO
					break;
				case "result":
					// We have received our roster
					if(s.Query != null && s.Query.NamespaceURI == "jabber:iq:roster")
					{
						Hashtable newRoster = new Hashtable();
						rosterView.Nodes.Clear();

						// Create new roster containing only those people in the query
						foreach(XmlNode item in s.Query.ChildNodes)
						{
							if(item.Name == "item")
							{
								string jid = item.Attributes["jid"].Value;
								Contact c = new Contact();							
								c.BaseJabberId = jid;
								c.Name = item.Attributes["name"] == null ? jid : item.Attributes["name"].Value;
								newRoster.Add(jid, c);
							}
						}

						// Preserve resource information for people in our old roster
						foreach(Contact c in roster.Values)
						{
							if(newRoster[c.BaseJabberId] != null) newRoster[c.BaseJabberId] = c;
						}

						roster = newRoster;
							
						refreshRosterView();
					}
					break;
			}
		}