示例#1
0
        private void ctxMnuRosterChat_Click(object sender, System.EventArgs e)
        {
            ListViewItem itm = GetSelectedListViewItem();

            if (itm != null)
            {
                if (!Util.Forms.ContainsKey(itm.Tag))
                {
                    frmChat f = new frmChat(new Jid((string)itm.Tag), XmppCon, itm.Text);
                    f.Show();
                }
            }
        }
示例#2
0
        /// <summary>
        /// We received a message
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="msg"></param>
        private void XmppCon_OnMessage(object sender, agsXMPP.protocol.client.Message msg)
        {
            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 OnMessageDelegate(XmppCon_OnMessage), new object[] { sender, msg });
                return;
            }

            // check for xData Message
            Element e = msg.SelectSingleElement(typeof(Data));

            if (e != null)
            {
                Data xdata = e as Data;
                if (xdata.Type == XDataFormType.form)
                {
                    // This is not supported by the WM5 MiniClient sample
                }
            }
            else
            {
                if (msg.Type == MessageType.chat)
                {
                    if (!Util.Forms.ContainsKey(msg.From.Bare))
                    {
                        ListViewItem itm  = FindRosterListViewItem(msg.From);
                        string       nick = itm == null ? msg.From.Bare : itm.Text;

                        frmChat f = new frmChat(msg.From, XmppCon, nick);
                        f.Show();
                        f.IncomingMessage(msg);
                    }
                }
                else if (msg.Type == MessageType.normal)
                {
                    frmMsg fMsg = new frmMsg(msg);
                    fMsg.Show();
                }
                else if (msg.Type == MessageType.headline)
                {
                    // not handeled in this example
                }
            }
        }
示例#3
0
        /// <summary>
        /// We received a message
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="msg"></param>
        private void XmppCon_OnMessage(object sender, agsXMPP.protocol.client.Message msg)
        {
            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 OnMessageDelegate(XmppCon_OnMessage), new object[] { sender, msg });
                return;
            }

            // check for xData Message
            Element e = msg.SelectSingleElement(typeof(Data));

            if (e != null)
            {
                Data xdata = e as Data;
                if (xdata.Type == XDataFormType.form)
                {
                    frmXData fXData = new frmXData(xdata);
                    fXData.Text = "xData Form from " + msg.From.ToString();
                    fXData.Show();
                }
            }
            else
            {
                if (!Util.Forms.ContainsKey(msg.From.Bare))
                {
                    ListViewItem itm  = FindRosterListViewItem(msg.From);
                    string       nick = itm == null ? msg.From.Bare : itm.Text;

                    frmChat f = new frmChat(msg.From, XmppCon, nick);
                    f.Show();
                    f.IncomingMessage(msg);
                }
            }
        }
示例#4
0
文件: frmMain.cs 项目: don59/agsXmpp
		private void ctxMnuRosterChat_Click(object sender, System.EventArgs e)
		{
			ListViewItem itm = GetSelectedListViewItem();
			if (itm != null)
			{
				if (!Util.Forms.ContainsKey(itm.Tag))
				{				
					frmChat f = new frmChat(new Jid( (string) itm.Tag ), XmppCon, itm.Text);
					f.Show();					
				}		
			}			
		}
示例#5
0
文件: frmMain.cs 项目: don59/agsXmpp
		/// <summary>
		/// We received a message
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="msg"></param>
		private void XmppCon_OnMessage(object sender, agsXMPP.protocol.client.Message msg)
		{
			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 OnMessageDelegate(XmppCon_OnMessage), new object[]{sender, msg});
				return;
			}

			// check for xData Message
			Element e = msg.SelectSingleElement(typeof(Data));
			if (e != null)
			{	
				Data xdata = e as Data;
				if (xdata.Type == XDataFormType.form)
				{
					frmXData fXData = new frmXData(xdata);
					fXData.Text = "xData Form from " + msg.From.ToString();
					fXData.Show();
				}
			}
			else
			{
				if (!Util.Forms.ContainsKey(msg.From.Bare))
				{
					ListViewItem itm = FindRosterListViewItem(msg.From);
					string nick =  itm == null ? msg.From.Bare : itm.Text;
				
					frmChat f = new frmChat(msg.From, XmppCon, nick);
					f.Show();
					f.IncomingMessage(msg);
				}
			}
		}
示例#6
0
文件: frmMain.cs 项目: don59/agsXmpp
        /// <summary>
		/// We received a message
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="msg"></param>
		private void XmppCon_OnMessage(object sender, agsXMPP.protocol.client.Message msg)
		{
            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 OnMessageDelegate(XmppCon_OnMessage), new object[] { sender, msg });
                return;
            }

            // Dont handle GroupChat Messages here, they have their own callbacks in the
            // GroupChat Form
            if (msg.Type == MessageType.groupchat)
                return;

            if (msg.Type == MessageType.error)
            {
                //Handle errors here
                // we dont handle them in this example
                return;
            }			

			// check for xData Message
			
			if (msg.HasTag(typeof(Data)))
			{	
                Element e = msg.SelectSingleElement(typeof(Data));                
				Data xdata = e as Data;
				if (xdata.Type == XDataFormType.form)
				{
					frmXData fXData = new frmXData(xdata);
					fXData.Text = "xData Form from " + msg.From.ToString();
					fXData.Show();
				}
			}
            else if(msg.HasTag(typeof(agsXMPP.protocol.extensions.ibb.Data)))
            {
                // ignore IBB messages
                return;
            }
			else
			{
                if (msg.Body != null)
                {
                    if (!Util.ChatForms.ContainsKey(msg.From.Bare))
                    {
                        RosterNode rn = rosterControl.GetRosterItem(msg.From);
                        string nick = msg.From.Bare;
                        if (rn != null)
                            nick = rn.Text;

                        frmChat f = new frmChat(msg.From, XmppCon, nick);
                        f.Show();
                        f.IncomingMessage(msg);
                    }
                }
			}
		}
示例#7
0
文件: frmMain.cs 项目: don59/agsXmpp
 private void chatToolStripMenuItem_Click(object sender, EventArgs e)
 {
     RosterNode node = rosterControl.SelectedItem();
     if (node != null)
     {
         if (!Util.ChatForms.ContainsKey(node.RosterItem.Jid.ToString()))
         {
             frmChat f = new frmChat(node.RosterItem.Jid, XmppCon, node.Text);
             f.Show();
         }
     }			
 }
示例#8
0
文件: frmMain.cs 项目: phiree/dzdocs
        /// <summary>
        /// We received a message
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="msg"></param>
        private void XmppCon_OnMessage(object sender, agsXMPP.protocol.client.Message msg)
        {
            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 OnMessageDelegate(XmppCon_OnMessage), new object[] { sender, msg });
                return;
            }

            // check for xData Message
            Element e = msg.SelectSingleElement(typeof(Data));
            if (e != null)
            {
                Data xdata = e as Data;
                if (xdata.Type == XDataFormType.form)
                {
                    // This is not supported by the WM5 MiniClient sample
                }
            }
            else
            {
                if (msg.Type == MessageType.chat)
                {
                    if (!Util.Forms.ContainsKey(msg.From.Bare))
                    {
                        ListViewItem itm = FindRosterListViewItem(msg.From);
                        string nick = itm == null ? msg.From.Bare : itm.Text;

                        frmChat f = new frmChat(msg.From, XmppCon, nick);
                        f.Show();
                        f.IncomingMessage(msg);
                    }
                }
                else if (msg.Type == MessageType.normal)
                {
                    frmMsg fMsg = new frmMsg(msg);
                    fMsg.Show();
                }
                else if (msg.Type == MessageType.headline)
                {
                    // not handeled in this example
                }
            }
        }