Beispiel #1
0
        /// <summary>
        /// 重新登录功能
        /// </summary>
        /// <param name="ISAutoLogin">是否读取配置文件的自动登录</param>
        ///<param name="isLogin">是否显示错误登录功能</param>
        public void LogOut(bool ISAutoLogin,bool isLogin)
        {
            this.Hide();
            OverTrayTimer.Enabled = false;
            timer1.Enabled = false;
            try
            {
                XmppCon.OnClose -= new ObjectHandler(XmppCon_OnClose);
                XmppCon.OnError -= new ErrorHandler(XmppCon_OnError);//错误
                XmppCon.Close();
            }
            catch (Exception)
            {

            }
            this.WindowState = FormWindowState.Minimized;
            this.ShowInTaskbar = false;

            friendListView.Rosters.Clear();
            friendListView.Groups.Clear();
            friendListView.Controls.Clear();

            try
            {
                login = new LoginFrom(this, isLogin);
                login.ISAutoLogin = ISAutoLogin;//不从配置中读取设置
                login.Login_Event += new LoginFrom.LoginDelegate(login_Login_Event);
                login.Show();

                XmppCon.OnClose += new ObjectHandler(XmppCon_OnClose);
                XmppCon.OnError += new ErrorHandler(XmppCon_OnError);
            }
            catch (Exception)
            {

            }
        }
Beispiel #2
0
        private void QQMainForm_Load(object sender, EventArgs e)
        {
            Util.VcardChangeEvent += new Util.ObjectHandler(Util_VcardChangeEvent);

            OverTrayTimer.Interval = 250;
            OverTrayTimer.Enabled = true;
            OverTrayTimer.Tick += new EventHandler(OverTrayTimer_Tick);

            stateButton1.State = 1;
            //this.WindowState = FormWindowState.Minimized;
            this.Hide();
            this.ShowInTaskbar = false;

            XmppCon.SocketConnectionType = CSS.IM.XMPP.net.SocketConnectionType.Direct;//使用TCP/IP的方式进行连接
            //XmppCon.ClientSocket.ConnectTimeout = 1000;
            XmppCon.OnReadXml += new XmlHandler(XmppCon_OnReadXml);//发送数据的XML
            XmppCon.OnWriteXml += new XmlHandler(XmppCon_OnWriteXml);//接收数据的XML

            XmppCon.OnRosterStart += new ObjectHandler(XmppCon_OnRosterStart);//获取联系人列表
            XmppCon.OnRosterEnd += new ObjectHandler(XmppCon_OnRosterEnd);//获取列表结束
            XmppCon.OnRosterItem += new CSS.IM.XMPP.XmppClientConnection.RosterHandler(XmppCon_OnRosterItem);//得到列表项目

            //XmppCon.OnAgentStart += new ObjectHandler(XmppCon_OnAgentStart);//代理
            //XmppCon.OnAgentEnd += new ObjectHandler(XmppCon_OnAgentEnd);
            //XmppCon.OnAgentItem += new agsXMPP.XmppClientConnection.AgentHandler(XmppCon_OnAgentItem);

            XmppCon.OnLogin += new ObjectHandler(XmppCon_OnLogin);//登录
            XmppCon.OnClose += new ObjectHandler(XmppCon_OnClose);
            XmppCon.OnError += new ErrorHandler(XmppCon_OnError);//错误
            XmppCon.OnPresence += new PresenceHandler(XmppCon_OnPresence);//状态
            XmppCon.OnMessage += new MessageHandler(XmppCon_OnMessage);//消息
            XmppCon.OnIq += new IqHandler(XmppCon_OnIq);//ID

            //XmppCon.OnAuthError += new XmppElementHandler(XmppCon_OnAuthError);//登录错误

            XmppCon.OnSocketError += new ErrorHandler(XmppCon_OnSocketError);
            //XmppCon.OnStreamError += new XmppElementHandler(XmppCon_OnStreamError);

            XmppCon.OnReadSocketData += new CSS.IM.XMPP.net.BaseSocket.OnSocketDataHandler(ClientSocket_OnReceive);//查看socket接收数据
            XmppCon.OnWriteSocketData += new CSS.IM.XMPP.net.BaseSocket.OnSocketDataHandler(ClientSocket_OnSend);//查看socket发送数据

            //XmppCon.ClientSocket.OnValidateCertificate += new System.Net.Security.RemoteCertificateValidationCallback(ClientSocket_OnValidateCertificate);//SSL验证

            //XmppCon.OnXmppConnectionStateChanged += new XmppConnectionStateHandler(XmppCon_OnXmppConnectionStateChanged);
            //XmppCon.OnSaslStart += new SaslEventHandler(XmppCon_OnSaslStart);

            //discoManager = new DiscoManager(XmppCon);

            XmppCon.OnAuthError += new XmppElementHandler(XmppCon_OnAuthError);
            discoManager = new DiscoManager(XmppCon);

            CSS.IM.XMPP.Factory.ElementFactory.AddElementType("UserRemark", null, typeof(Settings.TUserRemark));//用户备注表

            CSS.IM.XMPP.Factory.ElementFactory.AddElementType("Login", null, typeof(Settings.Login));//注册login类
            CSS.IM.XMPP.Factory.ElementFactory.AddElementType("Paths", null, typeof(Settings.Paths));//注册Paths类
            CSS.IM.XMPP.Factory.ElementFactory.AddElementType("ServerInfo", null, typeof(Settings.ServerInfo));//注册ServerInfo类

            //XmppCon.Server = "DUBIN-PC";
            //XmppCon.Server = "192.168.0.44";
            //XmppCon.Server = "192.168.0.102";

            //XmppCon.Server = System.Net.Dns.GetHostByAddress("6.136.8.14").HostName.ToString();
            //XmppCon.Server = "192.168.0.36";

            //XmppCon.Username = "******";
            //XmppCon.Password = "******";
            XmppCon.Resource = "CSS.IM.App";
            XmppCon.Priority = 10;
            //XmppCon.UseSSL=false;
            XmppCon.AutoResolveConnectServer = true;
            XmppCon.UseCompression = false;
            //XmppCon.RegisterAccount = true;  //是否注册.
            XmppCon.EnableCapabilities = true;
            XmppCon.ClientVersion = "1.0";
            XmppCon.Capabilities.Node = "http://www.css.com.cn/";

            friendListView.friend_qcm_MouseClickEvent += new QQListViewEx.friend_qcm_MouseClick_Delegate(friendListView_friend_qcm_MouseClickEvent);//好友右单击事件
            friendListView.OpenChatEvent += new QQListViewEx.delegate_openChat(friendListView_OpenChatEvent);

            //System.IO.MemoryStream memory = new MemoryStream();
            //this.Icon.Save(memory);

            //FileStream fileStream = new FileStream("C:\\a.jpg", FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite);
            //fileStream.Write(memory.ToArray(), 0, memory.ToArray().Length);
            //fileStream.Flush();
            //fileStream.Close();

            timer1.Enabled = false;
            timer1.Interval = 200;
            ShowInTaskbar = false;

            ChatMessageBox.GetInstance(this).OpenChatEvent += new ChatMessageBox.delegate_openChat(QQMainForm_OpenChatEvent);

            try
            {
                login = new LoginFrom(this, false);
                login.ISAutoLogin = true;
                login.Login_Event += new LoginFrom.LoginDelegate(login_Login_Event);
                login.Show();
            }
            catch (Exception)
            {

            }
        }