private void VcardResult(object sender, IQ iq, object data) { if (InvokeRequired) { // Windows Forms are not Thread Safe, we need to invoke this :( // We're not in the UI thread, so we need to call BeginInvoke BeginInvoke(new IqCB(VcardResult), new object[] { sender, iq, data }); return; } if (iq.Type == IqType.result) { Vcard vcard = iq.Vcard; if (vcard != null) { txt_name.Text = vcard.Fullname; txt_nickname.Text = vcard.Nickname; txt_birthday.Text = vcard.Birthday.ToString("yyy-MM-dd"); txt_desc.Text = vcard.Description; Photo photo = vcard.Photo; if (photo != null) pic_top.Image = vcard.Photo.Image; else pic_top.Image = CSS.IM.UI.Util.ResClass.GetHead("big194"); } } }
public void SendSetingCell(object sender, IQ iq, object data) { if (InvokeRequired) { this.Invoke(new IqCB(SendSetingCell), new object[] {sender,iq,data }); } System.Diagnostics.Debug.WriteLine("返回的数据:\n" + iq.ToString()); btn_cancel_Click(null, null); }
public void GroupCallMethod(object sender, IQ iq, object data) { DiscoItems items = iq.Query as DiscoItems; DiscoItem[] itms=items.GetDiscoItems(); foreach (DiscoItem item in itms) { //Debug.WriteLine(item.Name); //Debug.WriteLine(item.Jid); IQ itemIQ = new IQ(IqType.get); itemIQ.Namespace = null; itemIQ.Id = CSS.IM.XMPP.Id.GetNextId(); itemIQ.To = item.Jid; CSS.IM.XMPP.protocol.Base.Query query = new CSS.IM.XMPP.protocol.Base.Query(); query.Namespace = CSS.IM.XMPP.Uri.DISCO_INFO; itemIQ.AddChild(query); XmppCon.IqGrabber.SendIq(itemIQ, new IqCB(ItemCallMethod), null, true); } }
public void OnDiscoInfoResult(object sender, IQ iq, object data) { // <iq from='proxy.cachet.myjabber.net' to='[email protected]/Exodus' type='result' id='jcl_19'> // <query xmlns='http://jabber.org/protocol/disco#info'> // <identity category='proxy' name='SOCKS5 Bytestreams Service' type='bytestreams'/> // <feature var='http://jabber.org/protocol/bytestreams'/> // <feature var='http://jabber.org/protocol/disco#info'/> // </query> // </iq> if (iq.Type == IqType.result) { if (iq.Query is DiscoInfo) { DiscoInfo di = iq.Query as DiscoInfo; Jid jid = iq.From; if (di.HasFeature(CSS.IM.XMPP.Uri.IQ_SEARCH)) { if (!Util.Services.Search.Contains(jid)) { if (!Util.Services.Rooms.Contains(jid)) { if ("conference" == di.SelectElements("identity").Item(0).GetAttribute("category")) { Util.Services.Rooms.Add(jid); } } if (!Util.Services.Finds.Contains(jid)) { if ("directory" == di.SelectElements("identity").Item(0).GetAttribute("category")) { Util.Services.Finds.Add(jid); } } Util.Services.Search.Add(jid); this.Invoke(new OnChatGroupAddDelegate(OnChatGroupAdd), new object[] { jid }); } } else if (di.HasFeature(CSS.IM.XMPP.Uri.BYTESTREAMS)) { if (!Util.Services.Proxy.Contains(jid)) Util.Services.Proxy.Add(jid); } } } }
private void VcardResult(object sender, IQ iq, object data) { if (InvokeRequired) { // Windows Forms are not Thread Safe, we need to invoke this :( // We're not in the UI thread, so we need to call BeginInvoke BeginInvoke(new IqCB(VcardResult), new object[] { sender, iq, data }); return; } if (iq.Type == IqType.result) { Vcard vcard = iq.Vcard; Util.vcard = vcard; if (vcard != null) { //Program.NikName = vcard.Nickname; Photo photo = vcard.Photo; if (photo != null) userImg.Image = vcard.Photo.Image; } description.Text = vcard.Description; } }
void pswd_form_ChatsPasswordSetEvent(IQ iq,string pswd) { if (OpenChatGroupWindowsEvent != null) { OpenChatGroupWindowsEvent(iq.From, pswd); } }
/// <summary> /// Sends an Iq synchronous and return the response or null on timeout. /// Timeout time used is <see cref="SynchronousTimeout"/> /// </summary> /// <param name="iq">The IQ to send</param> /// <returns>The response IQ or null on timeout</returns> public IQ SendIq(IQ iq) { return SendIq(iq, m_SynchronousTimeout); }
/// <summary> /// Send an IQ Request and store the object with callback in the Hashtable /// </summary> /// <param name="iq">The iq to send</param> /// <param name="cb">the callback function which gets raised for the response</param> /// <param name="cbArg">additional object for arguments</param> public void SendIq(IQ iq, IqCB cb, object cbArg,bool isTo) { // check if the callback is null, in case of wrong usage of this class //if (cb != null) //{ // TrackerData td = new TrackerData(); // td.cb = cb; // td.data = cbArg; // m_grabbing[iq.Id] = td; //} //m_connection.Send(iq); // check if the callback is null, in case of wrong usage of this class if (cb != null) { TrackerData td = new TrackerData(); td.cb = cb; td.data = cbArg; m_grabbing[iq.Id] = td; //iq��CSS.IM.XMPP�з���Iq�ڵ�ʱ����iq.RemoveAttribute("to") //iq.RemoveAttribute("to"); } m_connection.Send(iq); }
private void ProcessDiscoInfo(IQ iq) { IQ diiq = new IQ(); diiq.To = iq.From; diiq.Id = iq.Id; diiq.Type = IqType.result; diiq.Query = xmppConnection.DiscoInfo; xmppConnection.Send(diiq); }
private void SessionResult(object sender, IQ iq, object data) { if (iq.Type == IqType.result) { m_XmppClient.DoChangeXmppConnectionState(XmppConnectionState.SessionStarted); m_XmppClient.RaiseOnLogin(iq); } else if (iq.Type == IqType.error) { } }
public void TreeResulit(object sender, IQ iq, object data) { if (InvokeRequired) { this.Invoke(new IqCB(TreeResulit), new object[] { sender, iq, data }); } try { if (treeView1.Nodes.Count != 0) { return; } Element orgs = iq.Query.FirstChild; if (orgs != null) { TreeNode root_treenode = new TreeNode(orgs.GetAttribute("orgName").ToString(), 0, 0); root_treenode.Tag = iq.Query.GetAttribute("filename").ToString(); treeView1.Nodes.Add(root_treenode); ElementList org_list = orgs.SelectElements("org"); MarkOrgTOList(org_list, root_treenode); } } catch (Exception) { } try { List<int> selectNodeIndex = new List<int>(); if (Selectnode != null) { for (TreeNode i = Selectnode; i.Parent != null; i = i.Parent) { selectNodeIndex.Insert(0, i.Index); } TreeNode selecNodeout = treeView1.Nodes[0]; selecNodeout.Expand(); for (int i = 0; i < selectNodeIndex.Count; i++) { selecNodeout = selecNodeout.Nodes[selectNodeIndex[i]]; selecNodeout.Expand(); } } } catch (Exception) { } }
/// <summary> /// 设置聊天室的参数 /// </summary> public void SetConfiguration() { IQ IqSetRquest = new IQ(IqType.set); IqSetRquest.Namespace = null; IqSetRquest.Id = CSS.IM.XMPP.Id.GetNextId(); IqSetRquest.To = this.MJid; CSS.IM.XMPP.protocol.Base.Query query = new CSS.IM.XMPP.protocol.Base.Query(); query.Namespace = CSS.IM.XMPP.Uri.MUC_OWNER; Data query_x = new Data(XDataFormType.submit); Field field1 = new Field(); field1.Var = "FORM_TYPE"; field1.Type = FieldType.Hidden; field1.AddValue(Features.FEAT_MUC_ROOMCONFIG); query_x.AddField(field1); Field field2 = new Field(); field2.Var = "muc#roomconfig_roomname"; field2.Type = FieldType.Text_Single; field2.AddValue(txt_name.Texts.Trim()); query_x.AddField(field2); Field field3 = new Field(); field3.Var = "muc#roomconfig_roomdesc"; field3.Type = FieldType.Text_Single; field3.AddValue(txt_tm.Texts.Trim()); query_x.AddField(field3); Field field4 = new Field(); field4.Var = "muc#roomconfig_persistentroom"; field4.Type = FieldType.Boolean; field4.AddValue(txt_gd.Checked == true ? "1" : "0"); query_x.AddField(field4); Field field5 = new Field(); field5.Var = "muc#roomconfig_passwordprotectedroom"; field5.Type = FieldType.Boolean; field5.AddValue(txt_sy.Checked == true ? "1" : "0"); query_x.AddField(field5); Field field6 = new Field(); field6.Var = "muc#roomconfig_roomsecret"; field6.Type = FieldType.Text_Private; field6.AddValue(txt_pswd2.Texts.ToString()); query_x.AddField(field6); Field field7 = new Field(); field7.Var = "muc#roomconfig_roomowners"; field7.Type = FieldType.Jid_Multi; field7.AddValue(XmppCon.MyJID.ToString()); query_x.AddField(field7); query.AddChild(query_x); IqSetRquest.AddChild(query); XmppCon.IqGrabber.SendIq(IqSetRquest, new IqCB(SetConfigurationCell), null, true); }
private void BindResult(object sender, IQ iq, object data) { // Once the server has generated a resource identifier for the client or accepted the resource // identifier provided by the client, it MUST return an IQ stanza of type "result" // to the client, which MUST include a <jid/> child element that specifies the full JID for // the connected resource as determined by the server: // Server informs client of successful resource binding: // <iq type='result' id='bind_2'> // <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'> // <jid>[email protected]/someresource</jid> // </bind> // </iq> if (iq.Type == IqType.result) { // i assume the server could assign another resource here to the client // so grep the resource assigned by the server now Element bind = iq.SelectSingleElement(typeof(Bind)); if (bind != null) { Jid jid = ((Bind)bind).Jid; m_XmppClient.Resource = jid.Resource; m_XmppClient.Username = jid.User; } m_XmppClient.DoChangeXmppConnectionState(XmppConnectionState.Binded); m_XmppClient.m_Binded = true; m_XmppClient.DoRaiseEventBinded(); // success, so start the session now m_XmppClient.DoChangeXmppConnectionState(XmppConnectionState.StartSession); SessionIq sIq = new SessionIq(IqType.set, new Jid(m_XmppClient.Server)); m_XmppClient.IqGrabber.SendIq(sIq, new IqCB(SessionResult), null); } else if (iq.Type == IqType.error) { // TODO, handle bind errors } }
/// <summary> /// 创建房间回调事件 /// </summary> /// <param name="sender"></param> /// <param name="iq"></param> /// <param name="data"></param> public void CreateReservedRoom(object sender, IQ iq, object data) { mucManager.JoinRoom(iq.From, XmppCon.MyJID.User,true);; mucManager.AcceptDefaultConfiguration(MJid); }
/// <summary> /// 设置聊天室参数后返回信息 /// </summary> /// <param name="sender"></param> /// <param name="iq"></param> /// <param name="data"></param> public void SetConfigurationCell(object sender, IQ iq, object data) { if (CreateRoomOverEvent!=null) { CreateRoomOverEvent(MJid, txt_pswd2.Texts.ToString()); } //Debug.WriteLine("设置聊天室参数后的信息:"+iq.ToString()); }
/// <summary> /// 获取对方的名片 /// </summary> /// <param name="sender"></param> /// <param name="iq"></param> /// <param name="data"></param> private void VcardResult(object sender, IQ iq, object data) { if (InvokeRequired) { // Windows Forms are not Thread Safe, we need to invoke this :( // We're not in the UI thread, so we need to call BeginInvoke BeginInvoke(new IqCB(VcardResult), new object[] { sender, iq, data }); return; } try { if (iq.Type == IqType.result) { Vcard vcard = iq.Vcard; if (vcard != null) { if (vcard.Nickname.Trim().Length>0) { this._NickName=vcard.Nickname; } else { this._NickName=TO_Jid.User;; } nikeName.Text = this._NickName; this.Text = "正在与[" + (this._NickName != "" ? this._NickName : _NickName) + "]对话"; //txt_name.Text = vcard.Fullname; //txt_nickname.Text = vcard.Nickname; //txt_birthday.Text = vcard.Birthday.ToString(); //txt_desc.Text = vcard.Description; Photo photo = vcard.Photo; if (photo != null) friendHead.Image = vcard.Photo.Image; else friendHead.Image = CSS.IM.UI.Util.ResClass.GetHead("big194"); if (!OnLine) { friendHead.Image = Util.MarkTopHead(friendHead.Image); } if (photo!=null) if (photo.Image != null) { photo.Image.Dispose(); } vcard = null; } } } catch (Exception) { } System.GC.Collect(); }
/// <summary> /// Callback /// </summary> /// <param name="sender"></param> /// <param name="iq"></param> /// <param name="data"></param> public void OnDiscoServerResult(object sender, IQ iq, object data) { if (iq.Type == IqType.result) { Element query = iq.Query; if (query != null && query.GetType() == typeof(DiscoItems)) { DiscoItems items = query as DiscoItems; DiscoItem[] itms = items.GetDiscoItems(); foreach (DiscoItem itm in itms) { if (itm.Jid != null) discoManager.DiscoverInformation(itm.Jid, new IqCB(OnDiscoInfoResult), itm); } } } }
public void XmppCon_OnLogin(object sender) { if (InvokeRequired) { BeginInvoke(new CSS.IM.XMPP.ObjectHandler(XmppCon_OnLogin), new object[] { sender }); return; } Program.LocalHostIP =IPAddress.Parse(XmppCon.ClientSocket.LocalHostIP);//设置本地IP地址 VcardIq viq = new VcardIq(IqType.get, null, new Jid(XmppCon.MyJID.User)); XmppCon.IqGrabber.SendIq(viq, new IqCB(VcardResult), null); Program.UserName = XmppCon.MyJID.User;//保存登录的用户名 notifyIcon1.Visible = true; waiting.Close(); XmppCon.Show = ShowType.NONE; XmppCon.SendMyPresence(); DiscoServer();//获取各种服务器 this.NikeName = XmppCon.Username; this.ShowInTaskbar = false; this.Show(); this.WindowState = FormWindowState.Normal; friendListView.Conn = XmppCon; friendListView.AddGroup("我的联系人"); friendListView.UpdateLayout(3, 0); this.TopMost = true; this.Show(); this.Activate(); this.TopMost = false; //获取新的组织结构图 IQ tree_iq = new IQ(IqType.get); tree_iq.Id = CSS.IM.XMPP.Id.GetNextId(); tree_iq.Namespace = null; CSS.IM.XMPP.protocol.Base.Query query = new CSS.IM.XMPP.protocol.Base.Query(); query.Attributes.Add("filename", "new"); query.Namespace = "xmlns:org:tree"; tree_iq.AddChild(query); XmppCon.IqGrabber.SendIq(tree_iq, new IqCB(TreeResulit), null); }
public void OnSearchFieldsResult(object sender, IQ iq, object data) { Debug.WriteLine(iq.ToString()); if (iq.Type == IqType.result) { //String command = Console.ReadLine(); } else if (iq.Type == IqType.error) { } }
private void UseChatGetInfo(object sender, IQ iq, object data) { if (InvokeRequired) { this.Invoke(new IqCB(UseChatGetInfo),new object[]{sender,iq,data}); } pswd_form.iq = iq; pswd_form.ChatsPasswordSetEvent += new ChatsGroupPasswordForm.ChatsPasswordSetDelegate(pswd_form_ChatsPasswordSetEvent); bool isPassword = true; for (int i = 0; i < iq.Query.SelectElements("feature").Count; i++) { if (iq.Query.SelectElements("feature").Item(i).Attribute("var") == "muc_unsecured") { isPassword = false; } } if (isPassword) { if (pswd_form.IsDisposed) { pswd_form = new ChatsGroupPasswordForm(); } try { pswd_form.Show(); } catch (Exception) { } } else { //<presence id="OUw29-39" to="[email protected]/songques"> // <x xmlns="http://jabber.org/protocol/muc"></x> // <x xmlns="vcard-temp:x:update"><photo>50bc87cccff6f129652471a2b1196c97203f5abb</photo></x> // <x xmlns="jabber:x:avatar"><hash>50bc87cccff6f129652471a2b1196c97203f5abb</hash></x> //</presence> if (OpenChatGroupWindowsEvent!=null) { OpenChatGroupWindowsEvent(iq.From, ""); } } }
public void XmppCon_OnIq(object sender, IQ iq) { if (InvokeRequired) { // Windows Forms are not Thread Safe, we need to invoke this :( // We're not in the UI thread, so we need to call BeginInvoke BeginInvoke(new IqHandler(XmppCon_OnIq), new object[] { sender, iq }); return; } if (iq != null) { // No Iq with query if (iq.HasTag(typeof(CSS.IM.XMPP.protocol.extensions.si.SI))) { if (iq.Type == IqType.error) { CSS.IM.XMPP.protocol.extensions.si.SI si = iq.SelectSingleElement(typeof(CSS.IM.XMPP.protocol.extensions.si.SI)) as CSS.IM.XMPP.protocol.extensions.si.SI; CSS.IM.XMPP.protocol.extensions.filetransfer.File file = si.File; if (file != null) { // somebody wants to send a file to us //if (!Util.ChatForms.ContainsKey(iq.From.Bare))//正常消息 //{ // //RosterNode rn = rosterControl.GetRosterItem(msg.From); // //string nick = msg.From.Bare; // //if (rn != null) // // nick = rn.Text; // ChatForm chatForm = new ChatForm(iq.From, XmppCon, iq.From.Bare); // chatForm.Show(); // //chatForm.IncomingMessage(msg); // chatForm.FileTransfer(iq); //} } } } else { } } }
private void VcardResult(object sender, IQ iq, object data) { if (InvokeRequired) { BeginInvoke(new IqCB(VcardResult), new object[] { sender, iq, data }); return; } if (iq.Type == IqType.result) { Vcard vcard = iq.Vcard; if (vcard != null) { Photo photo = vcard.Photo; if (photo != null) { headImgbak = new Bitmap(photo.BitImage, new Size(40, 40)); } else { headImgbak = ResClass.GetHead(FriendInfo.HeadIMG); } NickName = vcard.Nickname.Trim() == "" ? MJid.User : vcard.Nickname.Trim(); NameRmark = NickName;//没办法的处理以后有血液的时候在说 FriendInfo.Description = vcard.Description; FriendInfo.NikeName = NickName; } else { headImgbak = ResClass.GetHead(FriendInfo.HeadIMG); } headImg = new Bitmap(headImgbak); } ChangeInfo(_friendInfo); System.GC.Collect(); }
private void OnIq(object sender, IQ iq) { // DiscoInfo if (m_AutoAnswerDiscoInfoRequests && iq.Query is DiscoInfo && iq.Type == IqType.get) ProcessDiscoInfo(iq); }
/// <summary> /// 获取临时组服务器 /// </summary> /// <param name="sender"></param> /// <param name="iq"></param> /// <param name="data"></param> public void ChatGroupResulit(object sender, IQ iq, object data) { //Debug.WriteLine(iq.Query); if (iq.Type == IqType.result) { if (iq.Query is DiscoItems) { DiscoItems items = iq.Query as DiscoItems; DiscoItem[] itms = items.GetDiscoItems(); foreach (DiscoItem itm in itms) { if (itm.Jid != null) //discoManager.DiscoverInformation(itm.Jid, new IqCB(OnDiscoInfoResult), itm); Debug.WriteLine(itm); } } } }
/// <summary> /// Send an IQ Request and store the object with callback in the Hashtable /// </summary> /// <param name="iq">The iq to send</param> /// <param name="cb">the callback function which gets raised for the response</param> public void SendIq(IQ iq, IqCB cb) { SendIq(iq, cb, null); }
/// <summary> /// 查看联系人详细信息事件、删除、备注 /// </summary> /// <param name="sender"></param> /// <param name="item"></param> public void friendListView_friend_qcm_MouseClickEvent(object sender, Friend item, String type) { CSS.IM.XMPP.protocol.iq.roster.RosterItem ritem = friendListView.SelectedFriend.Ritem; switch (type) { case "vcar": VcardForm vcardForm = new VcardForm(ritem.Jid, XmppCon); try { vcardForm.Show(); } catch (Exception) { } break; case "chat": if (!Util.ChatForms.ContainsKey(item.Ritem.Jid.ToString())) { try { ChatForm chat = new ChatForm(item.Ritem.Jid, XmppCon, item.NikeName); chat.UpdateFriendOnline(item.IsOnline);//设置好友在线状态 chat.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { try { ChatForm chatform = Util.ChatForms[item.Ritem.Jid.ToString()] as ChatForm; chatform.WindowState = FormWindowState.Normal; chatform.Activate(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } break; case "dele": Jid jid = item.Ritem.Jid; Friend friend = new Friend(); friend.NikeName = item.Ritem.Jid.User; friend.Description = "";//心情 friend.HeadIMG = "big1"; friend.IsSysHead = true; friend.State = 1; if (item.Ritem.GetGroups().Count > 0) { CSS.IM.XMPP.protocol.Base.Group g = (CSS.IM.XMPP.protocol.Base.Group)item.Ritem.GetGroups().Item(0); int groupID = 0; foreach (var groups in friendListView.Groups) { if (groups.Value.Title == g.Name) { groupID = groups.Value.Id; } } //if (groupID == 0) //{ // friendListView.AddGroup(g.Name); // groupID = friendListView.Groups[g.Name].Id; // friendListView.UpdateLayout(3, groupID); //} friend.GroupID = groupID; friend.GroupName = g.Name; } else { //离线联系人 Group group = friendListView.Groups["我的联系人"]; friend.GroupID = group.Id; friend.GroupName = group.Title; } friend.Ritem = item.Ritem; friend.IsOnline = false; DialogResult msgResult=MsgBox.Show(this, "CSS&IM", "确认要删除联系人么?", MessageBoxButtons.YesNo); if (msgResult==DialogResult.Yes) { friendListView.RemoveFriend(friend); try { RosterIq riq = new RosterIq(); riq.Type = IqType.set; XmppCon.RosterManager.RemoveRosterItem(jid); } catch (Exception ex) { throw ex; } } break; case "move": MoveFriendGroup _MoveFriendGroup = new MoveFriendGroup(); Dictionary<string, Group> group_args = friendListView.Groups; string[] strvalue = new string[group_args.Count]; int index = 0; foreach (String keystr in group_args.Keys) { Group groupargs = group_args[keystr]; strvalue[index] = groupargs.Title; index++; } _MoveFriendGroup.basicComboBox1.Items = strvalue; _MoveFriendGroup.basicComboBox1.SelectIndex = 0; DialogResult reslut = _MoveFriendGroup.ShowDialog(); String groupupdate = _MoveFriendGroup.basicComboBox1.SelectItem.ToString(); String name_move = friendListView.SelectedFriend.Ritem.Jid.User; if (reslut == DialogResult.Yes) { foreach (String user_key in friendListView.Rosters.Keys) { if (friendListView.Rosters[user_key].Ritem.Jid.User == name_move) { Friend friend_old = friendListView.Rosters[user_key]; friendListView.RemoveFriend(friendListView.Rosters[user_key].Ritem.Jid.User); Group fgroup = friendListView.Groups[groupupdate]; friend_old.GroupID = fgroup.Id; friend_old.GroupName = fgroup.Title; friendListView.AddFriend(friend_old); friendListView.UpdateLayout(3, 0); break; } } CSS.IM.XMPP.protocol.Base.Group group_move = new CSS.IM.XMPP.protocol.Base.Group(groupupdate); CSS.IM.XMPP.protocol.Base.Item item_move = new CSS.IM.XMPP.protocol.Base.Item(); item_move.Namespace = null; item_move.AddChild(group_move); item_move.SetAttribute("jid", friendListView.SelectedFriend.Ritem.Jid); item_move.SetAttribute("subscripton", "from"); CSS.IM.XMPP.protocol.Base.Query query_move = new CSS.IM.XMPP.protocol.Base.Query(); query_move.Namespace = CSS.IM.XMPP.Uri.IQ_ROSTER; query_move.AddChild(item_move); IQ iq = new IQ(IqType.set); iq.GenerateId(); iq.Namespace = null; iq.AddChild(query_move); XmppCon.IqGrabber.SendIq(iq); } break; case "g_dele": break; case "remark": //RemarkFriendGroup _RemarkFriendGroup = new RemarkFriendGroup(); //Dictionary<string, Group> group_args = friendListView.Groups; //string[] strvalue = new string[group_args.Count]; //int index = 0; //foreach (String keystr in group_args.Keys) //{ // Group groupargs = group_args[keystr]; // strvalue[index] = groupargs.Title; // index++; //} //_MoveFriendGroup.basicComboBox1.Items = strvalue; //_MoveFriendGroup.basicComboBox1.SelectIndex = 0; //DialogResult reslut = _MoveFriendGroup.ShowDialog(); //String groupupdate = _MoveFriendGroup.basicComboBox1.SelectItem.ToString(); //String name_move = friendListView.SelectedFriend.Ritem.Jid.User; //if (reslut == DialogResult.Yes) //{ // foreach (String user_key in friendListView.Rosters.Keys) // { // if (friendListView.Rosters[user_key].Ritem.Jid.User == name_move) // { // Friend friend_old = friendListView.Rosters[user_key]; // friendListView.RemoveFriend(friendListView.Rosters[user_key].Ritem.Jid.User); // Group fgroup = friendListView.Groups[groupupdate]; // friend_old.GroupID = fgroup.Id; // friend_old.GroupName = fgroup.Title; // friendListView.AddFriend(friend_old); // friendListView.UpdateLayout(3, 0); // break; // } // } // CSS.IM.XMPP.protocol.Base.Group group_move = new CSS.IM.XMPP.protocol.Base.Group(groupupdate); // CSS.IM.XMPP.protocol.Base.Item item_move = new CSS.IM.XMPP.protocol.Base.Item(); // item_move.Namespace = null; // item_move.AddChild(group_move); // item_move.SetAttribute("jid", friendListView.SelectedFriend.Ritem.Jid); // item_move.SetAttribute("subscripton", "from"); // CSS.IM.XMPP.protocol.Base.Query query_move = new CSS.IM.XMPP.protocol.Base.Query(); // query_move.Namespace = CSS.IM.XMPP.Uri.IQ_ROSTER; // query_move.AddChild(item_move); // IQ iq = new IQ(IqType.set); // iq.GenerateId(); // iq.Namespace = null; // iq.AddChild(query_move); // XmppCon.IqGrabber.SendIq(iq); break; default: break; } }
/// <summary> /// Sends an Iq synchronous and return the response or null on timeout /// </summary> /// <param name="iq">The IQ to send</param> /// <param name="timeout"></param> /// <returns>The response IQ or null on timeout</returns> public IQ SendIq(CSS.IM.XMPP.protocol.client.IQ iq, int timeout) { synchronousResponse = null; AutoResetEvent are = new AutoResetEvent(false); SendIq(iq, new IqCB(SynchronousIqResult), are); if (!are.WaitOne(timeout, true)) { // Timed out lock (m_grabbing) { if (m_grabbing.ContainsKey(iq.Id)) m_grabbing.Remove(iq.Id); } return null; } return synchronousResponse; }
private void SaveVcardResult(object sender, IQ iq, object data) { if (InvokeRequired) { // Windows Forms are not Thread Safe, we need to invoke this :( // We're not in the UI thread, so we need to call BeginInvoke BeginInvoke(new IqCB(SaveVcardResult), new object[] { sender, iq, data }); return; } if (iq.Type == IqType.result) { Util.VcardChangeEventMethod();//通知名片更新事件 MsgBox.Show(this, "CSS&IM", "备注保存成功!", MessageBoxButtons.OK); } else { MsgBox.Show(this, "CSS&IM", "备注保存失败", MessageBoxButtons.OK); } }
/// <summary> /// Callback for synchronous iq grabbing /// </summary> /// <param name="sender"></param> /// <param name="iq"></param> /// <param name="data"></param> private void SynchronousIqResult(object sender, IQ iq, object data) { synchronousResponse = iq; AutoResetEvent are = data as AutoResetEvent; are.Set(); }
/// <summary> /// 组件结构 /// </summary> private void TabTree() { pal_tree.Show(); treeView1.Nodes.Clear(); treeView1.BackColor = Color.White; treeView1.Width = pal_tree.Width - 2; treeView1.Height = pal_tree.Height - 2; treeView1.Scrollable = true; if (filename == null || filename.Trim().Length == 0) filename = "new"; //filename = "1340003997218.xml"; IQ tree_iq = new IQ(IqType.get); tree_iq.Id = CSS.IM.XMPP.Id.GetNextId(); tree_iq.Namespace = null; CSS.IM.XMPP.protocol.Base.Query query = new CSS.IM.XMPP.protocol.Base.Query(); query.Attributes.Add("filename", filename); query.Namespace = "xmlns:org:tree"; tree_iq.AddChild(query); XmppCon.IqGrabber.SendIq(tree_iq, new IqCB(TreeResulit), null); }