Exemplo n.º 1
0
        public MiniFriendControl(XmppClientConnection conn,Jid jid)
        {
            XmppConn = conn;
            MJid = jid;
            NickName = jid.User;

            bgImg = null;

            this.Anchor = ((AnchorStyles)(((AnchorStyles.Top | AnchorStyles.Left) | AnchorStyles.Right)));
            this.BackColor = Color.Transparent;

            if (Environment.OSVersion.Version.Major >= 6)
            {
                f = new Font("微软雅黑", 9F, FontStyle.Regular);
            }
            else
            {
                f = new Font("宋体", 9F, FontStyle.Regular);
            }

            this.SetStyle(ControlStyles.UserPaint, true);
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);

            try
            {
                VcardIq viq = new VcardIq(IqType.get, new Jid(jid.Bare));
                XmppConn.IqGrabber.SendIq(viq, new IqCB(VcardResult), null, true);
            }
            catch (Exception)
            {

            }
        }
Exemplo n.º 2
0
        public VcardForm(Jid jid, XmppClientConnection con)
        {
            InitializeComponent();
            _connection = con;
            VcardIq viq = new VcardIq(IqType.get, new Jid(jid.Bare));

            packetId = viq.Id;
            con.IqGrabber.SendIq(viq, new IqCB(VcardResult), null,true);
        }
Exemplo n.º 3
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.º 4
0
 /// <summary>
 /// 更新头像事件
 /// </summary>
 void _SetInfoForm_update_top_image_event()
 {
     VcardIq viq = new VcardIq(IqType.get, null, new Jid(XmppCon.MyJID.User));
     XmppCon.IqGrabber.SendIq(viq, new IqCB(VcardResult), null);
     _SetInfoForm = null;
 }
Exemplo n.º 5
0
        private void tb_Leave(object sender, EventArgs e)
        {
            bool change = true;

            QQtextBox tb = sender as QQtextBox;
            if (description.Text==tb.Text)
            {
                change = false;
            }
            else
            {
                change = true;
                description.Text = tb.Text;
            }
            tb.Dispose();
            Controls.Remove(tb);

            if (change)
            {
                Util.vcard.Description = description.Text;
                VcardIq viq = new VcardIq(IqType.set, null, new Jid(XmppCon.MyJID.User), Util.vcard);
                XmppCon.IqGrabber.SendIq(viq, new IqCB(SaveVcardResult), null);
            }
        }
Exemplo n.º 6
0
 public void UpdateImage()
 {
     VcardIq viq = new VcardIq(IqType.get, new Jid(FriendInfo.Ritem.Jid.Bare));
     XmppConn.IqGrabber.SendIq(viq, new IqCB(VcardResult), null, true);
     System.GC.Collect();
 }
Exemplo n.º 7
0
        public ChatFromMsg(Jid jid, XmppClientConnection Conn,string nickName)
        {
            InitializeComponent();
            RemotBaseUDPIP = IPAddress.Parse("127.0.0.1");

            AccepVideotInit = new AcceptVideoInitDelegate(AcceptVideoInitMethod);
            ReturnAcceptVideoInit = new ReturnAcceptVideoInitDelegate(ReturnAcceptVideoInitMethod);
            AcceptVideoOpen = new AcceptVideoOpenDelegate(AcceptVideoOpenMethod);
            FileSendRequestEvent = new FileSendRequestDelegate(FileSendRequestMethod);
            FileSendInitEvent = new FileSendInitDelegate(FileSendInitMethod);
            GetFtpFileEvent = new GetFtpFileDelegate(GetFtpFileAMethod);
            Red5AccpetEvent = new Red5AccpetDelegate(Red5AccpetMethod);
            Red5RefuseEvent = new Red5RefuseDelegate(Red5RefuseMethod);

            TO_Jid = jid;
            XmppConn = Conn;
            this._NickName = nickName;
            this.Text = "正在与[" + (nikeName.Text != "" ? nikeName.Text : _NickName) + "]对话";

            VcardIq viq = new VcardIq(IqType.get, new Jid(jid.Bare));
            XmppConn.IqGrabber.SendIq(viq, new IqCB(VcardResult), null, true);

            Util.ChatForms.Add(TO_Jid.Bare, this);
            nikeName.Text = _NickName;

            rtfSend.AllowDrop = true;
            rtfSend.DragDrop += new DragEventHandler(rtfSend_DragDrop);
            rtfSend.DragEnter += new DragEventHandler(rtfSend_DragEnter);

            XmppConn.MessageGrabber.Add(jid, new BareJidComparer(), new MessageCB(MessageCallback), null);

            //用于外部更新截图
            ScreenImageEvent += new ScreenImageDelegate(ChatFromMsg_ScreenImageEvent);
            Util.TO_Jid =TO_Jid;//公布对外的to_jid用于外部插入截图

            //初使化发送文件
            udpSendFile = new UdpSendFile(2);
            //sendFile.Log += new TraFransfersFileLogEventHandler(SendFileLog);
            udpSendFile.FileSendBuffer += new FileSendBufferEventHandler(FileSendBuffer);
            udpSendFile.FileSendAccept += new FileSendEventHandler(FileSendAccept);
            udpSendFile.FileSendRefuse += new FileSendEventHandler(FileSendRefuse);
            udpSendFile.FileSendCancel += new FileSendEventHandler(FileSendCancel);
            udpSendFile.FileSendComplete += new FileSendEventHandler(FileSendComplete);
            udpSendFile.Start();

            //初使化接收文件
            udpReceiveFile = new UdpReceiveFile(2);
            udpReceiveFile.RequestSendFile += new RequestSendFileEventHandler(RequestSendFile);
            udpReceiveFile.FileReceiveBuffer += new FileReceiveBufferEventHandler(FileReceiveBuffer);
            udpReceiveFile.FileReceiveComplete += new FileReceiveEventHandler(FileReceiveComplete);
            udpReceiveFile.FileReceiveCancel += new FileReceiveEventHandler(FileReceiveCancel);
            udpReceiveFile.Start();
        }
Exemplo n.º 8
0
        /// <summary>
        /// 更改好友状态 是否在线
        /// </summary>
        /// <param name="value"></param>
        public void UpdateFriendOnline(bool value)
        {
            OnLine = value;

            if (!OnLine)
            {
                if (avForm!=null)
                {
                    if (!avForm.IsDisposed)
                    {
                        avForm.isBtn_hangup = true;
                        avForm.AVClose();
                        avForm = null;
                    }
                }

                if (ravForm != null)
                {
                    if (!ravForm.IsDisposed)
                    {
                        ravForm.isBtn_hangup = true;
                        ravForm.AVClose();
                        ravForm = null;
                    }
                }

                if (fileTansfersContainer.Controls.Count > 0)
                {

                    List<FileTransfersItem> FTIList = new List<FileTransfersItem>();
                    foreach (Control citem in fileTansfersContainer.Controls)
                    {
                        FileTransfersItem item = citem as FileTransfersItem;
                        FTIList.Add(item);
                    }

                    foreach (FileTransfersItem item in FTIList)
                    {
                        if (item.Style == FileTransfersItemStyle.Send)
                        {
                            SendFileManager sendFileManager = item.Tag as SendFileManager;
                            udpSendFile.CancelSend(sendFileManager.MD5);
                            fileTansfersContainer.RemoveItem(item);
                            item.Dispose();
                        }
                        else if (item.Style == FileTransfersItemStyle.ReadyReceive)
                        {
                            RequestSendFileEventArgs rse = item.Tag as RequestSendFileEventArgs;
                            if (rse != null)
                            {
                                rse.Cancel = true;
                                fileTansfersContainer.RemoveItem(item);
                                item.Dispose();
                                udpReceiveFile.AcceptReceive(rse);
                            }
                        }
                        else if (item.Style == FileTransfersItemStyle.Receive)
                        {
                            ControlTag tag = item.Tag as ControlTag;
                            if (tag != null)
                            {
                                udpReceiveFile.CancelReceive(tag.MD5, tag.RemoteIP);
                                fileTansfersContainer.RemoveItem(item);
                                item.Dispose();
                            }
                        }
                        Thread.Sleep(500);
                    }

                    if (panel_function.Visible)
                    {
                        panel_function.Visible = false;
                        this.Width = this.Width - panel_function.Width;
                        panel_msg.Width = panel_msg.Width + panel_function.Width + 2;

                    }

                }

            }

            VcardIq viq = new VcardIq(IqType.get, TO_Jid);
            XmppConn.IqGrabber.SendIq(viq, new IqCB(VcardResult), null, true);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_save_Click(object sender, EventArgs e)
        {
            //if (txt_name.Texts.Trim().Length == 0)
            //{
            //    MsgBox.Show(this, "CSS&IM", "名字不能为空!", MessageBoxButtons.OK);
            //    return;
            //}

            if (txt_nickname.Texts.Trim().Length == 0)
            {
                txt_nickname.Texts = "";
                //MsgBox.Show(this, "CSS&IM", "名字不能为空!", MessageBoxButtons.OK);
                //return;
            }

            if (txt_desc.Texts.Trim().Length == 0)
            {
                txt_desc.Texts = "";
                //MsgBox.Show(this, "CSS&IM", "名字不能为空!", MessageBoxButtons.OK);
                //return;
            }

            //this.tab_state.Text = "数据更新中请等待……!";

            SaveVcard = new Vcard();
            SaveVcard.SetTag("sex", txt_sex.SelectText);//性别
            SaveVcard.Fullname = txt_name.Texts.ToString();//名字
            SaveVcard.Nickname = txt_nickname.Texts.ToString();//昵称
            SaveVcard.Birthday = txt_bar.Value;//生日

            Telephone telephone1 = new Telephone(TelephoneLocation.HOME, TelephoneType.VOICE, txt_phone1.Texts);//电话
            SaveVcard.AddTelephoneNumber(telephone1);
            Telephone telephone2 = new Telephone(TelephoneLocation.HOME, TelephoneType.CELL, txt_phone2.Texts);//手机
            SaveVcard.AddTelephoneNumber(telephone2);
            Email email = new Email(EmailType.HOME, txt_email.Texts, true);//邮箱
            SaveVcard.AddEmailAddress(email);
            Telephone telephone3 = new Telephone(TelephoneLocation.HOME, TelephoneType.FAX, txt_fox.Texts);//传真
            SaveVcard.AddTelephoneNumber(telephone3);
            SaveVcard.Title = txt_job.Texts;//职务
            SaveVcard.Description = txt_desc.Texts.ToString();//个人签名

            Organization org = new Organization(txt_companyName.Texts, txt_depar.Texts);//公司名称
            SaveVcard.Organization = org;

            Address address1=new Address(AddressLocation.WORK,"",txt_county.Texts,"",txt_province.Texts,txt_postalCode.Texts,txt_companyAddress.Texts,true);
            SaveVcard.AddAddress(address1);
            SaveVcard.Url = txt_companyDefault.Texts;

            Address address2 = new Address(AddressLocation.HOME, "", txt_meMarsk.Texts, "", txt_meDefault.Texts, "", "", true);
            SaveVcard.AddAddress(address2);

            Photo po = new Photo(pic_top.Image, ImageFormat.Jpeg);
            SaveVcard.Photo = po;

            VcardIq viq = new VcardIq(IqType.set, null, new Jid(XmppConn.MyJID.User), SaveVcard);
            XmppConn.IqGrabber.SendIq(viq, new IqCB(SaveVcardResult), null);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 更改好友状态 是否在线
        /// </summary>
        /// <param name="value"></param>
        public void UpdateFriendOnline(bool value)
        {
            OnLine = value;

            VcardIq viq = new VcardIq(IqType.get, to_Jid);
            _connection.IqGrabber.SendIq(viq, new IqCB(VcardResult), null, true);
        }
Exemplo n.º 11
0
        public ChatForm(Jid jid, XmppClientConnection con, string nickname)
        {
            InitializeComponent();

            _emotion = new EmotionDropdown();
            AcceptInit = new AcceptInitDelegate(AcceptInitMethod);
            ReturnAcceptInit = new ReturnAcceptInitDelegate(ReturnAcceptMethod);
            AcceptOpen = new AcceptOpenDelegate(AcceptOpenMethod);
            FileSendRequestEvent = new FileSendRequestDelegate(onUserFileSendRequest);
            FileSendInitEvent = new FileSendInitDelegate(FileSendInit);

            to_Jid = jid;
            _connection = con;
            _nickname = jid.User;
            this.nikeName.Text = nickname;

            VcardIq viq = new VcardIq(IqType.get, new Jid(jid.Bare));
            packetId = viq.Id;
            _connection.IqGrabber.SendIq(viq, new IqCB(VcardResult), null, true);

            Util.ChatForms.Add(to_Jid.Bare.ToLower(), this);
            nikeName.Text = _nickname;

            con.MessageGrabber.Add(jid, new BareJidComparer(), new MessageCB(MessageCallback), null);
            _emotion.EmotionContainer.ItemClick += new UI.Face.EmotionItemMouseEventHandler(EmotionContainer_ItemClick);

            friendHead.BackgroundImage = ResClass.GetImgRes("Padding4Normal");
            friendHead.Image = ResClass.GetHead("big194");

            rtfSend.AllowDrop = true;

            rtfSend.DragDrop += new DragEventHandler(rtfSend_DragDrop);
            rtfSend.DragEnter += new DragEventHandler(rtfSend_DragEnter);
        }
Exemplo n.º 12
0
        /// <summary>
        /// 登录成功事件
        /// </summary>
        /// <param name="sender"></param>
        public void XmppCon_OnLogin(object sender)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new CSS.IM.XMPP.ObjectHandler(XmppCon_OnLogin), new object[] { sender });
                return;
            }

            Program.UserName = XmppCon.Username;
            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;//保存登录的用户名

            notifyIcon_MessageQueue.Visible = true;
            waiting.Close();

            XmppCon.Show = ShowType.NONE;
            XmppCon.SendMyPresence();

            DiscoServer();//获取各种服务器

            this.NikeName = XmppCon.Username;
            this.ShowInTaskbar = false;
            this.Show();
            this.WindowState = FormWindowState.Normal;
            listView_fd.XmppConnection = XmppCon;

            listView_fd.AddGroup("我的联系人");
            listView_fd.UpdateLayout(3, 0);

            this.TopMost = true;
            this.Show();
            this.Activate();
            this.TopMost = false;

            #region 设置最后一次登录的用户
            Document hl_doc = new Document();
            Settings.HistoryLogin doc_HLlgin;
            if (!System.IO.File.Exists(CSS.IM.UI.Util.Path.HistoryFilename))
            {
                doc_HLlgin = new Settings.HistoryLogin();
                doc_HLlgin.LoginName = Program.UserName;
            }
            else
            {
                hl_doc.LoadFile(CSS.IM.UI.Util.Path.HistoryFilename);
                doc_HLlgin = hl_doc.RootElement as Settings.HistoryLogin;
                doc_HLlgin.LoginName = Program.UserName;
                hl_doc.RemoveAllChildNodes();

            }
            hl_doc.AddChild(doc_HLlgin);
            FileInfo file = new FileInfo(CSS.IM.UI.Util.Path.HistoryFilename);
            if (!File.Exists(file.DirectoryName))
            {
                Directory.CreateDirectory(file.DirectoryName);
            }
            hl_doc.Save(CSS.IM.UI.Util.Path.HistoryFilename);
            #endregion

            #region 创建服务配置文件
            Document vy_doc = new Document();
            Settings.Verify vy_doc_settings = new Settings.Verify();
            Settings.Login vy_doc_login = null;
            Settings.ServerInfo vy_doc_serverInfo = null;

            if (System.IO.File.Exists(string.Format(CSS.IM.UI.Util.Path.SettingsFilename,Program.UserName)))
            {
                vy_doc.LoadFile(string.Format(CSS.IM.UI.Util.Path.SettingsFilename, Program.UserName));

                vy_doc_login = vy_doc.RootElement.SelectSingleElement(typeof(Settings.Login)) as Settings.Login;
                vy_doc_serverInfo = vy_doc.RootElement.SelectSingleElement(typeof(Settings.ServerInfo)) as Settings.ServerInfo;
                vy_doc.RemoveAllChildNodes();
            }
            else
            {
                vy_doc_login = new Settings.Login();
                vy_doc_serverInfo = new Settings.ServerInfo();
                vy_doc_login.InitIal = true;//设置开机自动启动,默认为启动
            }

            vy_doc_login.Auto = login_user.Auto;
            vy_doc_login.Save = login_user.Save;
            vy_doc_login.Jid = new Jid(login_user.UserName);
            vy_doc_login.Password = login_user.PassWord;

            vy_doc_serverInfo.ServerIP = Program.ServerIP;
            vy_doc_serverInfo.ServerPort = Program.Port;

            vy_doc_settings.ServerInfo = vy_doc_serverInfo;
            vy_doc_settings.Login = vy_doc_login;

            vy_doc.ChildNodes.Add(vy_doc_settings);
            vy_doc.Save(string.Format(CSS.IM.UI.Util.Path.SettingsFilename, Program.UserName));
            CSS.IM.UI.Util.Path.Initial = vy_doc_login.InitIal;//设置开机自动启动
            #endregion

            #region 创建个人配置文件
            if (!System.IO.File.Exists(string.Format(CSS.IM.UI.Util.Path.ConfigFilename,Program.UserName)))
            {
                Document doc = new Document();
                Settings.Settings config = new Settings.Settings();
                CSS.IM.App.Settings.Paths path = new Settings.Paths();
                path.MsgPath = CSS.IM.UI.Util.Path.MsgPath;
                path.SelectSingleElement("MsgPath").SetAttribute("Enable", true);
                path.SystemPath = CSS.IM.UI.Util.Path.SystemPath;
                path.SelectSingleElement("SystemPath").SetAttribute("Enable", true);
                path.CallPath = CSS.IM.UI.Util.Path.CallPath;
                path.SelectSingleElement("CallPath").SetAttribute("Enable", true);
                path.FolderPath = CSS.IM.UI.Util.Path.FolderPath;
                path.SelectSingleElement("FolderPath").SetAttribute("Enable", true);
                path.GlobalPath = CSS.IM.UI.Util.Path.GlobalPath;
                path.SelectSingleElement("GlobalPath").SetAttribute("Enable", true);
                path.InputAlertPath = CSS.IM.UI.Util.Path.InputAlertPath;
                path.SelectSingleElement("InputAlertPath").SetAttribute("Enable", true);
                path.ReveiveSystemNotification = true;
                path.ChatOpen = true;
                path.SendKeyType = CSS.IM.UI.Util.Path.SendKeyType;//创建消息发送快捷键类型 默认为enter发送
                path.GetOutMsgKeyTYpe = "W+ Control+ Alt";//默认获取消息快捷按键
                path.ScreenKeyTYpe = "S+ Control+ Alt";//默认截图快捷按键
                path.FriendContainerType = true;//保存是大头像还是小头像 默认为小头像

                path.DefaultURL = "http://10.0.0.207:8080/bgtoa/eblueplugins/eblueim/forwardUrl.do?url=cmVkaXJlY3Q6L2luZGV4LmRv";//毛奇使用

                path.EmailURL = "http://10.0.0.207:8080/bgtoa/eblueplugins/eblueim/forwardUrl.do?url=cmVkaXJlY3Q6L2luZGV4LmRv";//毛奇使用

                config.Paths = path;

                CSS.IM.UI.Util.Path.DefaultURL = path.DefaultURL;

                BasicTextBox txt_temp = new BasicTextBox();

                CSS.IM.App.Settings.SFont font = new Settings.SFont();
                font.Name = txt_temp.Font.Name;
                font.Size = txt_temp.Font.Size;
                font.Bold = txt_temp.Font.Bold;
                font.Italic = txt_temp.Font.Italic;
                font.Strikeout = txt_temp.Font.Strikeout;
                config.Font = font;

                CSS.IM.App.Settings.SColor color = new Settings.SColor();
                Color top_cl = txt_temp.ForeColor;
                byte[] top_cby = BitConverter.GetBytes(top_cl.ToArgb());
                color.CA = top_cby[0];
                color.CR = top_cby[1];
                color.CG = top_cby[2];
                color.CB = top_cby[3];
                config.Color = color;

                doc.ChildNodes.Add(config);
                doc.Save(string.Format(CSS.IM.UI.Util.Path.ConfigFilename, Program.UserName));

                txt_temp.Dispose();
            }

            #endregion
        }
Exemplo n.º 13
0
 /// <summary>
 /// 更新头像事件
 /// </summary>
 private void update_head_portrait()
 {
     VcardIq viq = new VcardIq(IqType.get, null, new Jid(XmppCon.MyJID.User));
     XmppCon.IqGrabber.SendIq(viq, new IqCB(VcardResult), null);
     if (setInfoForm != null)
     {
         setInfoForm.Dispose();
         setInfoForm = null;
     }
 }
Exemplo n.º 14
0
        public void UpdateImage()
        {
            try
            {
                VcardIq viq = new VcardIq(IqType.get, new Jid(MJid.Bare));
                XmppConn.IqGrabber.SendIq(viq, new IqCB(VcardResult), null, true);
            }
            catch (Exception)
            {

            }
            System.GC.Collect();
        }
Exemplo n.º 15
0
        /// <summary>
        /// 表单加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SetInfoForm_Load(object sender, EventArgs e)
        {
            panel_basice.Visible = false;
            panel_extend.Visible = false;

            VcardIq viq = new VcardIq(IqType.get, new Jid(TO_Jid.Bare));
            packetId = viq.Id;
            XmppConn.IqGrabber.SendIq(viq, new IqCB(VcardResult), null, true);

            btn_basic_Click(null, null);
        }
Exemplo n.º 16
0
 public void UpdateImage()
 {
     VcardIq viq = new VcardIq(IqType.get,MJID);
     XmppConn.IqGrabber.SendIq(viq, new IqCB(VcardResult), null, true);
     System.GC.Collect();
 }