public void TestGroups() { RosterItem ri2 = XmppXElement.LoadXml(Resource.Get("Xmpp.Roster.item1.xml")).Cast <RosterItem>(); RosterItem ri3 = XmppXElement.LoadXml(Resource.Get("Xmpp.Roster.item2.xml")).Cast <RosterItem>(); Assert.Equal(3, ri2.GetGroups().Count); Assert.Equal(0, ri3.GetGroups().Count); ri3.AddGroup("Test"); Assert.Equal(1, ri3.GetGroups().Count); Assert.Equal("Test", ri3.GetGroups()[0]); }
public ChatFriend(RosterItem item) { User = item; var groups = item.GetGroups(); Group = groups.Item(0).InnerXml; }
/// <summary> /// 更新组名(未实现) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void renameGroupToolStripMenuItem_Click(object sender, EventArgs e) { RosterItem item = GetCurrentRosterItem(); if (item == null) { return; } String newName = item.Name; List <String> groups = new List <string>(); foreach (Element elm in item.GetGroups()) { groups.Add(elm.Value); } //wei=> InputValueForm form = new InputValueForm(); //wei=> form.InputText = item.Name; //wei=> if (form.ShowDialog(this.FindForm(),"重命名","好友名称") == DialogResult.Cancel) //wei=> { //wei=> return; //wei=> } //wei=>else //wei=> { // 新建组的名称 //wei=> newName = form.InputText; //wei=> } // 需要移动好友的JID赋值给变量 movingJid movingJid = item.Jid; // 设置同步标记为阻塞状态 movingJidFlag.Reset(); // 更新好友的组信息 //wei=>xmppClient.ClientConnection.RosterManager.UpdateRosterItem(movingJid, newName, groups.ToArray()); // 线程中等待移动好友到其他组成功 //wei=>ThreadUtils.Run(WaitUpdateRosterItem); }
public static void ProcessRosterIQSet(string username, IQ iq) { if (iq.Query.HasChildElements) { BLL.Users api = new BLL.Users(); foreach (Node r in iq.Query.ChildNodes) { Element el = r as Element; if (el != null) { RosterItem ri = el as RosterItem; if (el.HasAttribute("subscription")) { if (ri.Subscription == SubscriptionType.remove) { api.DeleteFriend(username, ri.Jid.User); } } if (el.HasChildElements) { NodeList li = el.ChildNodes; ElementList eli = ri.GetGroups(); string groupName = null; if (eli.Count > 0) { groupName = eli.Item(0).Value; } if (li.Count > 0) { api.ChangeFriendStatus(username, ri.Jid.User, groupName, null, true); } } } } iq.Type = IqType.get; ProcessRosterIQGet(username, iq); } }