Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        /// <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;
            }
        }
Exemplo n.º 3
0
        /// <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);
        }
Exemplo n.º 4
0
        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);
            }
        }
        /// <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);
        }
Exemplo n.º 6
0
 private void ChatGroupRoomsForm_Load(object sender, EventArgs e)
 {
     IQ groupIQ = new IQ(IqType.get);
     groupIQ.Id = CSS.IM.XMPP.Id.GetNextId();
     groupIQ.Namespace = null;
     groupIQ.To = MJid;
     CSS.IM.XMPP.protocol.Base.Query query = new CSS.IM.XMPP.protocol.Base.Query();
     query.Namespace = CSS.IM.XMPP.Uri.DISCO_ITEMS;
     groupIQ.AddChild(query);
     XmppCon.IqGrabber.SendIq(groupIQ, new IqCB(GroupCallMethod), null,true);
 }
Exemplo n.º 7
0
        private void list_rooms_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            IQ iq = list_rooms.Items[list_rooms.SelectedIndices[0]].Tag as IQ;
            IQ useChatIQ = new IQ();
            useChatIQ.Namespace = null;
            useChatIQ.Id = CSS.IM.XMPP.Id.GetNextId();
            useChatIQ.To = iq.From;
            useChatIQ.Type = IqType.get;

            Query useQuery = new Query();
            useQuery.Namespace = CSS.IM.XMPP.Uri.DISCO_INFO;
            useChatIQ.AddChild(useQuery);
            XmppCon.IqGrabber.SendIq(useChatIQ, new IqCB(UseChatGetInfo), null,true);
        }
        private void btn_submit_Click(object sender, EventArgs e)
        {
            //fields.RemoveTag("title");
            //fields.RemoveTag("instructions");

            //selectValue = fields.GetField("muc#roomconfig_maxusers").GetValue();
            //Option[] options = fields.GetField("muc#roomconfig_maxusers").GetOptions();
            //string[] cbb_roomconfig_maxusersValue = new string[options.Length];

            //chb_moderator

            //chb_participant

            //chb_visitor

            //for (int i = 0; i < options.Length; i++)
            //{
            //    cbb_roomconfig_maxusersValue[i] = options[i].GetValue();
            //}

            //cbb_roomconfig_maxusers.Items = cbb_roomconfig_maxusersValue;
            //cbb_roomconfig_maxusers.SelectItem = selectValue;

            fields.GetField("muc#roomconfig_roomsecret").SetValue(chb_roomconfig_roomsecret.Texts);//设置密码

            IQ iqSendSet = new IQ();
            iqSendSet.Namespace = null;
            iqSendSet.Id = CSS.IM.XMPP.Id.GetNextId();
            iqSendSet.To = to_jid;
            iqSendSet.Type = IqType.set;
            Query query = new Query();
            query.Namespace = CSS.IM.XMPP.Uri.MUC_OWNER;

            Data datas = new Data();
            datas.Namespace = CSS.IM.XMPP.Uri.X_DATA;
            datas.Type = XDataFormType.submit;
            //1
            Field FORM_TYPE = new Field();
            FORM_TYPE.Type = FieldType.Hidden;
            FORM_TYPE.Var = "FORM_TYPE";
            FORM_TYPE.SetValue(@"http://jabber.org/protocol/muc#roomconfig");
            datas.AddField(FORM_TYPE);
            //2
            Field roomconfig_roomname = new Field();
            roomconfig_roomname.Type = FieldType.Text_Single;
            roomconfig_roomname.Var = "muc#roomconfig_roomname";
            roomconfig_roomname.SetValue(txt_roomconfig_roomname.Texts.ToString());
            datas.AddField(roomconfig_roomname);
            //3
            Field roomconfig_roomdesc = new Field();
            roomconfig_roomdesc.Type = FieldType.Text_Single;
            roomconfig_roomdesc.Var = "muc#roomconfig_roomdesc";
            roomconfig_roomdesc.SetValue(txt_roomconfig_roomdesc.Texts.ToString());
            datas.AddField(roomconfig_roomdesc);
            //4
            Field roomconfig_changesubject = new Field();
            roomconfig_changesubject.Type = FieldType.Boolean;
            roomconfig_changesubject.Var = "muc#roomconfig_changesubject";
            roomconfig_changesubject.SetValueBool(chb_roomconfig_changesubject.Checked);
            datas.AddField(roomconfig_changesubject);
            //5
            Field roomconfig_maxusers = new Field();
            roomconfig_maxusers.Type = FieldType.List_Single;
            roomconfig_maxusers.Var = "muc#roomconfig_maxusers";
            roomconfig_maxusers.SetValue(cbb_roomconfig_maxusers.SelectItem.ToString());
            datas.AddField(roomconfig_maxusers);
            //6
            Field roomconfig_publicroom = new Field();
            roomconfig_publicroom.Type = FieldType.Boolean;
            roomconfig_publicroom.Var = "muc#roomconfig_publicroom";
            roomconfig_publicroom.SetValueBool(chb_roomconfig_publicroom.Checked);
            datas.AddField(roomconfig_publicroom);
            //7
            Field roomconfig_persistentroom = new Field();
            roomconfig_persistentroom.Type = FieldType.Boolean;
            roomconfig_persistentroom.Var = "muc#roomconfig_persistentroom";
            roomconfig_persistentroom.SetValueBool(chb_roomconfig_persistentroom.Checked);
            datas.AddField(roomconfig_persistentroom);
            //8
            Field roomconfig_moderatedroom = new Field();
            roomconfig_moderatedroom.Type = FieldType.Boolean;
            roomconfig_moderatedroom.Var = "muc#roomconfig_moderatedroom";
            roomconfig_moderatedroom.SetValueBool(chb_roomconfig_moderatedroom.Checked);
            datas.AddField(roomconfig_moderatedroom);
            //9
            Field roomconfig_membersonly = new Field();
            roomconfig_membersonly.Type = FieldType.Boolean;
            roomconfig_membersonly.Var = "muc#roomconfig_membersonly";
            roomconfig_membersonly.SetValueBool(chb_roomconfig_membersonly.Checked);
            datas.AddField(roomconfig_membersonly);
            //10
            Field roomconfig_allowinvites = new Field();
            roomconfig_allowinvites.Type = FieldType.Boolean;
            roomconfig_allowinvites.Var = "muc#roomconfig_allowinvites";
            roomconfig_allowinvites.SetValueBool(chb_roomconfig_allowinvites.Checked);
            datas.AddField(roomconfig_allowinvites);
            //11
            Field roomconfig_passwordprotectedroom = new Field();
            roomconfig_passwordprotectedroom.Type = FieldType.Boolean;
            roomconfig_passwordprotectedroom.Var = "muc#roomconfig_passwordprotectedroom";
            roomconfig_allowinvites.SetValueBool(chb_roomconfig_passwordprotectedroom.Checked);
            datas.AddField(roomconfig_passwordprotectedroom);
            //12
            Field roomconfig_whois = new Field();
            roomconfig_whois.Type = FieldType.Text_Single;
            roomconfig_whois.Var = "muc#roomconfig_whois";
            roomconfig_whois.SetValue(cbb_roomconfig_whois.SelectItem.ToString());
            datas.AddField(roomconfig_whois);
            //13
            Field roomconfig_enablelogging = new Field();
            roomconfig_enablelogging.Type = FieldType.Boolean;
            roomconfig_enablelogging.Var = "muc#roomconfig_enablelogging";
            roomconfig_enablelogging.SetValueBool(chb_roomconfig_enablelogging.Checked);
            datas.AddField(roomconfig_enablelogging);
            //14
            Field roomconfig_reservednick = new Field();
            roomconfig_reservednick.Type = FieldType.Boolean;
            roomconfig_reservednick.Var = "x-muc#roomconfig_reservednick";
            roomconfig_reservednick.SetValueBool(chb_roomconfig_reservednick.Checked);
            datas.AddField(roomconfig_reservednick);
            //15
            Field roomconfig_canchangenick = new Field();
            roomconfig_canchangenick.Type = FieldType.Boolean;
            roomconfig_canchangenick.Var = "x-muc#roomconfig_canchangenick";
            roomconfig_canchangenick.SetValueBool(chb_roomconfig_canchangenick.Checked);
            datas.AddField(roomconfig_canchangenick);
            //16
            Field roomconfig_registration = new Field();
            roomconfig_registration.Type = FieldType.Boolean;
            roomconfig_registration.Var = "x-muc#roomconfig_registration";
            roomconfig_registration.SetValueBool(chb_roomconfig_registration.Checked);
            datas.AddField(roomconfig_registration);

            Field roomconfig_roomadmins = new Field();
            roomconfig_roomadmins.Type = FieldType.Jid_Multi;
            roomconfig_roomadmins.Var = "muc#roomconfig_roomadmins";

            string[] itemsToStrings = new string[list_roomconfig_roomadmins.Items.Count];
            for (int i = 0; i <  list_roomconfig_roomadmins.Items.Count; i++)
            {
                itemsToStrings[i] =  list_roomconfig_roomadmins.Items[i].Text;
            }

            roomconfig_roomadmins.SetValues(itemsToStrings);
            datas.AddField(roomconfig_roomadmins);

            Field roomconfig_roomowners = new Field();
            roomconfig_roomowners.Type = FieldType.Jid_Multi;
            roomconfig_roomowners.Var = "muc#roomconfig_roomowners";

            if (list_roomconfig_roomowners.Items.Count>0)
            {
                itemsToStrings = new string[list_roomconfig_roomowners.Items.Count];
                for (int i = 0; i < list_roomconfig_roomowners.Items.Count; i++)
                {
                    itemsToStrings[i] = list_roomconfig_roomowners.Items[i].Text;
                }
            }
            else
            {
                string[] selectValues = fields.GetField("muc#roomconfig_roomadmins").GetValues();
                itemsToStrings = new string[selectValues.Length];

                for (int i = 0; i < selectValues.Length; i++)
                {
                    itemsToStrings[i] = selectValues[i];
                }
            }

            roomconfig_roomowners.SetValues(itemsToStrings);
            datas.AddField(roomconfig_roomowners);

            foreach (Field item in fields.GetFields())
            {
                datas.AddField(item);
            }

            query.AddChild(datas);
            iqSendSet.AddChild(query);

            System.Diagnostics.Debug.WriteLine("发送的数据:\n" + iqSendSet.ToString());
            XMPPConn.IqGrabber.SendIq(iqSendSet,new IqCB(SendSetingCell),null,true);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 查看联系人详细信息事件、删除、备注
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="item"></param>
        public void listView_fd_friend_qcm_MouseClickEvent(object sender, Friend item, String type)
        {
            CSS.IM.XMPP.protocol.iq.roster.RosterItem ritem = null;

            if (listView_fd.SelectFriend!=null)
            {
                ritem = listView_fd.SelectFriend.Ritem;
            }

            Document doc_setting = new Document();
            Settings.Settings config = new Settings.Settings();
            Settings.Paths path = null;

            switch (type)
            {
                case "vcar":
                    if (vcardForm == null || vcardForm.IsDisposed)
                    {
                        vcardForm = new VcardInfoForm(ritem.Jid, XmppCon);
                    }
                    vcardForm.Show();
                    vcardForm.Activate();

                    break;
                case "chat":
                    if (!Util.ChatForms.ContainsKey(item.Ritem.Jid.Bare))
                    {
                        try
                        {
                            string nickName = listView_fd.GetFriendNickName(item.Ritem.Jid.Bare);
                            ChatFromMsg chat = new ChatFromMsg(item.Ritem.Jid, XmppCon, nickName);
                            chat.UpdateFriendOnline(item.IsOnline);//设置好友在线状态
                            chat.Show();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }

                    }
                    else
                    {
                        try
                        {
                            ChatFromMsg chatform = Util.ChatForms[item.Ritem.Jid.Bare] as ChatFromMsg;
                            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 listView_fd.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 = listView_fd.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)
                    {
                        listView_fd.RemoveFriend(friend);

                        try
                        {
                            RosterIq riq = new RosterIq();
                            riq.Type = IqType.set;
                            XmppCon.RosterManager.RemoveRosterItem(jid);
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                    }
                    break;
                case "move":

                    if (moveFriendGroup == null || moveFriendGroup.IsDisposed)
                    {
                        moveFriendGroup = new MoveFriendGroup();
                    }
                    Dictionary<string, Group> group_args = listView_fd.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 Bare_move = listView_fd.SelectFriend.Ritem.Jid.Bare;
                    if (reslut == DialogResult.Yes)
                    {

                        foreach (String user_key in listView_fd.Rosters.Keys)
                        {
                            if (listView_fd.Rosters[user_key].Ritem.Jid.Bare == Bare_move)
                            {

                                Friend friend_old = listView_fd.Rosters[user_key];
                                listView_fd.RemoveFriend(listView_fd.Rosters[user_key].Ritem.Jid.Bare);

                                Group fgroup = listView_fd.Groups[groupupdate];
                                friend_old.GroupID = fgroup.Id;
                                friend_old.GroupName = fgroup.Title;

                                listView_fd.AddFriend(friend_old);
                                listView_fd.RefreshGroup();
                                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", listView_fd.SelectFriend.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;
                case "HeadSmall":
                    //listView_fd.FCType = FriendContainerType.Small;
                    CSS.IM.UI.Util.Path.FriendContainerType = false;
                    doc_setting.LoadFile(string.Format(CSS.IM.UI.Util.Path.ConfigFilename, Program.UserName));
                    path = doc_setting.RootElement.SelectSingleElement(typeof(Settings.Paths),false) as Settings.Paths;
                    path.FriendContainerType = CSS.IM.UI.Util.Path.FriendContainerType;
                    config.Paths = path;
                    config.Font = doc_setting.RootElement.SelectSingleElement(typeof(Settings.SFont), false) as Settings.SFont;
                    config.Color = doc_setting.RootElement.SelectSingleElement(typeof(Settings.SColor), false) as Settings.SColor;

                    doc_setting.Clear();
                    doc_setting.ChildNodes.Add(config);

                    try
                    {
                        doc_setting.Save(string.Format(CSS.IM.UI.Util.Path.ConfigFilename, Program.UserName));
                    }
                    catch (Exception)
                    {

                    }

                    listView_fd.FCType = CSS.IM.UI.Util.Path.FriendContainerType == true ? FriendContainerType.Big : FriendContainerType.Small;
                    chatHistory_lt.FCType = listView_fd.FCType;
                    listView_gp.FCType = listView_fd.FCType;
                    break;
                case "HeadBig":
                    //listView_fd.FCType = FriendContainerType.Small;
                    CSS.IM.UI.Util.Path.FriendContainerType = true;
                    doc_setting.LoadFile(string.Format(CSS.IM.UI.Util.Path.ConfigFilename, Program.UserName));
                    path = doc_setting.RootElement.SelectSingleElement(typeof(Settings.Paths),false) as Settings.Paths;
                    path.FriendContainerType = CSS.IM.UI.Util.Path.FriendContainerType;
                    config.Paths = path;
                    config.Font = doc_setting.RootElement.SelectSingleElement(typeof(Settings.SFont), false) as Settings.SFont;
                    config.Color = doc_setting.RootElement.SelectSingleElement(typeof(Settings.SColor), false) as Settings.SColor;

                    doc_setting.Clear();
                    doc_setting.ChildNodes.Add(config);
                    try
                    {
                        doc_setting.Save(string.Format(CSS.IM.UI.Util.Path.ConfigFilename, Program.UserName));
                    }
                    catch (Exception)
                    {

                    }
                    listView_fd.FCType = CSS.IM.UI.Util.Path.FriendContainerType == true ? FriendContainerType.Big : FriendContainerType.Small;
                    chatHistory_lt.FCType = listView_fd.FCType;
                    listView_gp.FCType = listView_fd.FCType;
                    break;
                default:
                    break;
            }
        }
Exemplo n.º 10
0
        private void btn_nt_Click(object sender, EventArgs e)
        {
            btn_fd.SelectTab = false;
            panel_fd.Visible = false;
            btn_gp.SelectTab = false;
            panel_gp.Visible = false;
            btn_nt.SelectTab = true;
            panel_nt.Visible = true;
            btn_lt.SelectTab = false;
            panel_lt.Visible = false;
            System.GC.Collect();

            //treeView_nt.Nodes.Clear();
            treeView_nt.BackColor = Color.White;
            treeView_nt.Width = panel_nt.Width - 2;
            treeView_nt.Height = panel_nt.Height - 2;
            treeView_nt.Scrollable = true;
            if (filename == null || filename.Trim().Length == 0)
                filename = "new";
            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);
        }
Exemplo n.º 11
0
 private void btnSet_MouseClick(object sender, MouseEventArgs e)
 {
     //chatGroupRoomSetForm.Show();
     //MucManager mucManagr = new MucManager(_connection);
     //mucManagr.RequestConfigurationForm(new Jid(to_Jid.Bare), new IqCB(RequestConfigurationForm), null);
     //<iq id="QBB6p-45" to="[email protected]" type="get"><query xmlns="http://jabber.org/protocol/muc#owner"></query></iq>
     IQ iq = new IQ();
     iq.Namespace = null;
     iq.Id = CSS.IM.XMPP.Id.GetNextId();
     iq.To = new Jid(to_Jid.User, to_Jid.Server, _connection.MyJID.User);
     iq.Type = IqType.get;
     Query query = new Query();
     query.Namespace = CSS.IM.XMPP.Uri.MUC_OWNER;
     iq.AddChild(query);
     _connection.IqGrabber.SendIq(iq, new IqCB(RequestConfigurationForm), null, true);
 }
Exemplo n.º 12
0
 /// <summary>
 /// 聊天室设置功能
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btn_set_Click(object sender, EventArgs e)
 {
     IQ iq = new IQ();
     iq.Namespace = null;
     iq.Id = CSS.IM.XMPP.Id.GetNextId();
     iq.To = new Jid(TO_Jid.User, TO_Jid.Server, XmppConn.MyJID.User);
     iq.Type = IqType.get;
     CSS.IM.XMPP.protocol.Base.Query query = new CSS.IM.XMPP.protocol.Base.Query();
     query.Namespace = CSS.IM.XMPP.Uri.MUC_OWNER;
     iq.AddChild(query);
     XmppConn.IqGrabber.SendIq(iq, new IqCB(RequestConfigurationForm), null, true);
 }