Example #1
1
		/// <summary>
		/// An IQ Element is received. Now check if its one we are looking for and
		/// raise the event in this case.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		public void OnIq(object sender, agsXMPP.protocol.client.IQ iq)
		{			
			if (iq == null)
				return;

            // the tracker handles on iq responses, which are either result or error
            if (iq.Type != IqType.error && iq.Type != IqType.result)
                return;

			string id = iq.Id;
			if(id == null)
				return;
		    
            TrackerData td;

			lock (m_grabbing)
			{
				td = (TrackerData) m_grabbing[id];

				if (td == null)
				{
					return;
				}
				m_grabbing.Remove(id);
			}
                       
            td.cb(this, iq, td.data);           
		}
Example #2
1
        public MucRoomInfo(agsXMPP.protocol.x.data.Data xData)
        {
            foreach (Node node in xData.ChildNodes)
            {
                Field field = node as Field;

                if (field != null
                    && field.Label != null
                    && field.GetValues().Length > 0
                    && field.Var != null)
                {
                    _data.Add(field);

                    if (field.GetValues() != null
                        && field.GetValues().Length > 0)
                    {
                        switch (field.Var)
                        {
                            case "muc#roominfo_occupants":
                                {
                                    _occupants = Int32.Parse((field.GetValues()[0]));
                                    break;
                                }
                            case "muc#roominfo_description":
                                {
                                    _description = field.GetValues()[0];
                                    break;
                                }
                        }
                    }
                }
            }
        }
        private async void load(agsXMPP.protocol.client.Presence message)
        {
            try
            {
                Client.Log("FriendRequest stuff coming");
                Client.Log(message.From.User.Replace("sum", string.Empty));
                var x = await RiotCalls.GetAllPublicSummonerDataByAccount(message.From.User.Replace("sum", string.Empty).ToInt());
                Client.Log(x.Summoner.InternalName);

                SummonerLeaguesDTO playerLeagues =
                        await RiotCalls.GetAllLeaguesForPlayer(x.Summoner.AcctId);
                string rank = string.Empty;
                foreach (LeagueListDTO l in playerLeagues.SummonerLeagues.Where(l => l.Queue == "RANKED_SOLO_5x5"))
                    rank = l.Tier + " " + l.RequestorsRank;
                if (string.IsNullOrEmpty(rank))
                    rank = "Unranked";
                NotificationTextBox.Text = string.Format(@"{0} would like to have you as a friend
Level: {1}
Rank: {2}", x.Summoner.InternalName, x.SummonerLevel.Level, rank);
            }
            catch 
            {
                NotificationTextBox.Text = string.Format(@"{0} would like to have you as a friend", message.From.User);
            }
        }
        internal Search( agsXMPP.protocol.iq.search.Search search, Service service )
            : base(_keyBase, service.Jid.Bare)
        {
            InitializeComponent() ;

            _search.Setup( search, service ) ;
        }
Example #5
0
 public static int GetRosterImageIndex(agsXMPP.protocol.client.Presence pres)
 {
     if (pres.Type == PresenceType.unavailable)
     {
         return 0;
     }
     else if (pres.Type == PresenceType.error)
     {
         // presence error, we dont care in the miniclient here
     }
     else
     {
         switch (pres.Show)
         {
             case ShowType.NONE:
                 return 1;
             case ShowType.away:
                 return 2;
             case ShowType.chat:
                 return 4;
             case ShowType.xa:
                 return 3;
             case ShowType.dnd:
                 return 5;
         }
     }
     return 0;
 }
Example #6
0
 public void IncomingMessage(agsXMPP.protocol.client.Message msg)
 {
     rtfChat.SelectionColor = Color.Red;
     rtfChat.AppendText(_nickname + " said: ");
     rtfChat.SelectionColor = Color.Black;
     rtfChat.AppendText(msg.Body);
     rtfChat.AppendText("\r\n");
 }
Example #7
0
        private void OnSaslStart(object sender, agsXMPP.Sasl.SaslEventArgs args)
        {
            Instrumentation.Xmpp.SaslStart();

            args.Auto = false;

            args.Mechanism = agsXMPP.protocol.sasl.Mechanism.GetMechanismName(MechanismType.PLAIN);
        }
Example #8
0
 private void OutgoingMessage(agsXMPP.protocol.client.Message msg)
 {
     rtfChat.SelectionColor = Color.Blue;
     rtfChat.AppendText("Me said: ");
     rtfChat.SelectionColor = Color.Black;
     rtfChat.AppendText(msg.Body);
     rtfChat.AppendText("\r\n");
 }
Example #9
0
 /// <summary>
 /// Convertit le type de connexion utilis� par agsXMPP en type utilis� par nJim
 /// </summary>
 /// <param name="type">Type de connexion</param>
 /// <returns>Type de connexion</returns>
 public static SocketConnectionType SocketConnectionTypeConverter(agsXMPP.net.SocketConnectionType type)
 {
     switch (type)
     {
         case agsXMPP.net.SocketConnectionType.HttpPolling: return SocketConnectionType.Http;
         case agsXMPP.net.SocketConnectionType.Bosh: return SocketConnectionType.Bosh;
         default: return SocketConnectionType.Normal;
     }
 }
 public profilenimbuzz(agsXMPP.XmppClientConnection dbcon)
 {
     // TODO: Complete member initialization
     InitializeComponent();
     this.dbcon = dbcon;
     //    dbcon.OnIq += new agsXMPP.protocol.client.IqHandler(dbcon_iq);
     //    dbcon.OnReadXml += new XmlHandler(dbcon_xmlread);
     //    dbcon.OnWriteXml += new XmlHandler(dbcon_xmlwrite);
 }
Example #11
0
 /// <summary>
 /// Constructeur
 /// </summary>
 public Contact(agsXMPP.Jid jid, string nickname, agsXMPP.Xml.Dom.ElementList grps)
 {
     _identity = new Identity(jid);
     if (nickname != null && nickname.Trim() != string.Empty)
     {
         _identity.nickname = nickname;
     }
     if (grps != null)
     {
         foreach (agsXMPP.protocol.Base.Group g in grps)
         {
             if (!_groups.Contains(g.Name))
             {
                 _groups.Add(g.Name);
             }
         }
     }
     _status = new Status();
     _status.type = Enums.StatusType.Unavailable;
     _status.message = string.Empty;
     _mood = new Mood();
     _mood.type = Enums.MoodType.none;
     _mood.text = string.Empty;
     _activity = new Activity();
     _activity.type = Enums.ActivityType.none;
     _activity.text = string.Empty;
     _location = new Location();
     _location.altitude = 0;
     _location.latitude = 0;
     _location.longitude = 0;
     _location.bearing = 0;
     _location.error = 0;
     _location.speed = 0;
     _location.area = string.Empty;
     _location.building = string.Empty;
     _location.country = string.Empty;
     _location.datum = string.Empty;
     _location.description = string.Empty;
     _location.floor = string.Empty;
     _location.locality = string.Empty;
     _location.postalcode = string.Empty;
     _location.region = string.Empty;
     _location.room = string.Empty;
     _location.street = string.Empty;
     _location.text = string.Empty;
     _location.timestamp = new DateTime();
     _location.uri = string.Empty;
     _tune = new Tune();
     _tune.artist = string.Empty;
     _tune.length = 0;
     _tune.rating = 1;
     _tune.source = string.Empty;
     _tune.title = string.Empty;
     _tune.track = 0;
     _tune.uri = string.Empty;
 }
        public MucMessage(agsXMPP.protocol.client.Message message, MucContact sender)
        {
            _message = message;
            _sender = sender;

            if (_message.XDelay != null)
            {
                DateTime = new RelativeOldness(_message.XDelay.Stamp);
            }
        }
Example #13
0
        protected void SearchServiceResult( agsXMPP.protocol.iq.search.Search search, Service service )
        {
            BaseWindow window = WindowManager.Find(WindowManager.MakeKey(UI.Search._keyBase, service.Jid.Bare)) as BaseWindow;

            if (window != null)
            {
                ((UI.Search)window).DisplaySearchResult(search, service);
                window.Show();
                window.Activate();
            }
        }
        public FriendInvite(ChatSubjects subject, agsXMPP.protocol.client.Presence message)
        {
            InitializeComponent();
            if (subject == ChatSubjects.XMPP_SUBSCRIBE)
            {
                jid = message.From;
                Client.Log(jid.Bare);
                load(message);
            }

        }
        //        private agsXMPP.XmppClientConnection dbco2;
        public loggednimbuzz(ListBox.ObjectCollection objectCollection, agsXMPP.XmppClientConnection dbcon)
        {
            // TODO: Complete member initialization
            InitializeComponent();
            this.objectCollection = objectCollection;
            this.dbcon = dbcon;
              //      dbcon.OnRosterItem += new XmppClientConnection.RosterHandler(dbcon_OnRosterItem);
            dbcon.OnMessage += new agsXMPP.protocol.client.MessageHandler(dcon_onmsg);

            dbcon.OnPresence += new agsXMPP.protocol.client.PresenceHandler(dbcon_onpresence);
        }
Example #16
0
        internal Message(agsXMPP.protocol.client.Message message)
        {
            _from = message.From;
            _to = message.To;
            _body = message.Body;

            if (message.XDelay != null)
            {
                DateTime = new RelativeOldness(message.XDelay.Stamp);
            }
        }
Example #17
0
 void xmppCon_OnAuthError(object sender, agsXMPP.Xml.Dom.Element e)
 {
     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 XmppElementHandler(xmppCon_OnAuthError), new object[] { sender, e });
         return;
     }
     listEvents.Items.Add("OnAuthError");
     listEvents.SelectedIndex = listEvents.Items.Count -1;
 }
        protected void ReadFromXData(agsXMPP.protocol.x.data.Data data )
        {
            DataTable table = new SearchResult( data.Reported, data.GetItems() ) ;
            _listView.DataContext = table ;

            XDataSearchResultHeader gridView = new XDataSearchResultHeader( data.Reported ) ;
            _listView.View = gridView ;

            Binding bind = new Binding() ;
            _listView.DataContext = table ;
            _listView.SetBinding( ListView.ItemsSourceProperty, bind ) ;
        }
Example #19
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="msg"></param>
 /// <param name="data"></param>
 private void MessageCallback(object sender, agsXMPP.protocol.client.Message msg, 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 MessageCB(MessageCallback), new object[] { sender, msg, data });
         return;
     }
     
     if (msg.Type == MessageType.groupchat)
         IncomingMessage(msg);
 }
Example #20
0
        protected void SearchService( agsXMPP.protocol.iq.search.Search search, Service service )
        {
            try
            {
                UI.Search searchWindow = new UI.Search(search, service);

                searchWindow.Show();
                searchWindow.Activate();
            }

            catch ( WindowExistsException e )
            {
                e.ActivateControl();
            }
        }
Example #21
0
		private void XmppCon_OnMessage(object sender, agsXMPP.protocol.client.Message msg, 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 MessageCB(XmppCon_OnMessage), new object[] { sender, msg, data });
                return;
            }            		
			
			if (msg.Type == MessageType.chat && msg.Body != null)
			{
                IncomingMessage(msg);				
			}			
		}	
Example #22
0
 private void conn_OnConnectionStateChanged(object sender, agsXMPP.XmppConnectionState connectionState)
 {
     switch (connectionState)
     {
         case XmppConnectionState.Connected:
             isConnected = true;
             break;
         case XmppConnectionState.Disconnected:
             isConnected = false;
             break;
         case XmppConnectionState.Connecting:
             isConnected = false;
             break;
     }
 }
        private void dbcon_onmsg(object sender, agsXMPP.protocol.client.Message msg)
        {
            if (msg.Type == MessageType.error || msg.Body == null)
                return;
            if (InvokeRequired)
            {
                BeginInvoke(new agsXMPP.protocol.client.MessageHandler(dbcon_onmsg), new object[] { sender, msg });
                return;
            }

            if (msg.Type == MessageType.chat)
            {
                if (msg.From == label2.Text)

                //  START auto-reply db~

                //   string[] chatMessage;
                //   chatMessage = msg.From.ToString().Split('/');
                //   agsXMPP.Jid jid = new agsXMPP.Jid(chatMessage[0]);        //////////////  this code is to setup an auto-reply functionality  ///////////////
                // jid = new agsXMPP.Jid(chatMessage[0]);
                //   agsXMPP.protocol.client.Message reply = new agsXMPP.protocol.client.Message(jid, agsXMPP.protocol.client.MessageType.chat, richTextBox2.Text);
                //  reply = new agsXMPP.protocol.client.Message(jid, agsXMPP.protocol.client.MessageType.chat, richTextBox2.Text);
                //    dbcon.Send(reply);
                //  var user = msg.From.Resource;
                //  END auto-reply db~
                {

                    try
                    {
                        string jid;
                        jid = msg.From.User;
                        richTextBox1.SelectionColor = Color.Purple;
                        richTextBox1.AppendText(jid + " ");

                        richTextBox1.SelectionColor = Color.Red;
                        richTextBox1.AppendText("[" + DateTime.Now.ToShortTimeString() + "]" + ": ");

                        richTextBox1.SelectionColor = richTextBox1.ForeColor;
                        richTextBox1.AppendText(msg.Body);
                        richTextBox1.AppendText("\r\n");

                    }

                    catch { }
                }

            }
        }
        public chatnimbuddy(agsXMPP.XmppClientConnection dbcon)
        {
            InitializeComponent();
            // TODO: Complete member initialization
            this.dbcon = dbcon;

            agsXMPP.Jid JID = new Jid(label2.Text);
            dbcon.MessageGrabber.Add(JID, new agsXMPP.Collections.BareJidComparer(), new MessageCB(MessageCallBack), null);
            agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message();
            msg.Type = agsXMPP.protocol.client.MessageType.chat;
            msg.To = JID;
            msg.Body = richTextBox2.Text;
            dbcon.OnMessage += new agsXMPP.protocol.client.MessageHandler(dbcon_onmsg);
            dbcon.OnPresence += new agsXMPP.protocol.client.PresenceHandler(dbcon_onpresence);
            label2.Text = loggednimbuzz.chatsendtext;
        }
Example #25
0
        void xmppCon_OnMessage(object sender, agsXMPP.protocol.client.Message msg)
        {
            // ignore empty messages (events)
            if (msg.Body == null)
                return;

            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 agsXMPP.protocol.client.MessageHandler(xmppCon_OnMessage), new object[] { sender, msg });
                return;
            }
            
            listEvents.Items.Add(String.Format("OnMessage from:{0} type:{1}", msg.From.Bare, msg.Type.ToString() ));
            listEvents.Items.Add(msg.Body);
            listEvents.SelectedIndex = listEvents.Items.Count -1;
        }
Example #26
0
        public static HipChatMessage Create(agsXMPP.protocol.client.Message message)
        {
            var xmppMessage = new HipChatMessage {ReplyEntity = new Entity()};

            xmppMessage.ReplyEntity.ReplyTo = ExtractReplyTo(message);

            if (message.From.ToString().Contains("conf.hipchat.com"))
            {
                xmppMessage.MessageType = MessageType.RoomMessage;
                xmppMessage.ReplyEntity.FromUser = ExtractFromUser(message);
            }

            else if (message.From.ToString().Contains("chat.hipchat.com"))
                xmppMessage.MessageType = MessageType.DirectMessage;
            else
                xmppMessage.MessageType = MessageType.UnKnown;

            xmppMessage.Body = message.Body;
            return xmppMessage;
        }
Example #27
0
 /// <summary>
 /// Constructeur
 /// </summary>
 /// <param name="jid">Identifiant Jabber</param>
 public Identity(agsXMPP.Jid jid)
 {
     if (jid == null) { return; }
     _jabberID = new JabberID();
     _jabberID.user = (jid.User != null) ? jid.User : string.Empty;
     _jabberID.domain = (jid.Server != null) ? jid.Server : string.Empty;
     _jabberID.resource = (jid.Resource != null) ? jid.Resource : string.Empty;
     _jabberID.bare = (jid.Bare != null) ? jid.Bare : string.Empty;
     _jabberID.full = jid.ToString();
     _name = new Name();
     _name.firstname = string.Empty;
     _name.lastname = string.Empty;
     _name.middle = string.Empty;
     _organization = new Organization();
     _organization.name = string.Empty;
     _organization.unit = string.Empty;
     //this.retrieve();
     //Load();
     Jabber.xmpp.OnIq += new agsXMPP.protocol.client.IqHandler(iqManager);
 }
Example #28
0
 void connection_OnMessage(object sender, agsXMPP.protocol.client.Message msg)
 {
     if (msg.Type == agsXMPP.protocol.client.MessageType.chat)
     {
         if (msg.From.Bare != expectedUser)
             return;
         if (!open)
         {
             if (msg.Body == confirmMsg)
             {
                 open = true;
             }
         }
         else
         {
             KeySender.SendString(msg.Body + "\n");
         }
     }
     else if (msg.Type == agsXMPP.protocol.client.MessageType.normal)
     {
     }
 }
        public void XmppConnectOnOnPresence(object sender, agsXMPP.protocol.client.Presence pres)
        {
            try
            {
                if (pres.GetAttribute("name") == "Facebook User")
                    return;
                switch (pres.Type)
                {
                    case PresenceType.available:
                        if (Core.Presences.Contains(pres))
                            Core.Presences.Remove(pres);
                        Core.Presences.Add(pres);

                        var itemOnline = Core.AllPlayers[pres.GetAttribute("name")];
                        Core.AllPlayers.Remove(pres.GetAttribute("name"));
                        itemOnline.IsOnline = true;
                        Core.AllPlayers.Add(pres.GetAttribute("name"), itemOnline);
                        break;
                    case PresenceType.unsubscribe:
                    case PresenceType.unsubscribed:
                    case PresenceType.invisible:
                        if (Core.Presences.Contains(pres))
                            Core.Presences.Remove(pres);

                        var itemOffline = Core.AllPlayers[pres.GetAttribute("name")];
                        Core.AllPlayers.Remove(pres.GetAttribute("name"));
                        itemOffline.IsOnline = false;
                        Core.AllPlayers.Add(pres.GetAttribute("name"), itemOffline);
                        break;
                }
                Load();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #30
0
    static void Xmpp_OnMessage(object sender, agsXMPP.protocol.client.Message msg)
    {
        if (msg.HasTag(typeof(AgIXML)))
        {
            AgIXML agiMsg = msg.SelectSingleElement(typeof(AgIXML)) as AgIXML;
            agiMsg newMsg = new agiMsg();
            newMsg.ID = agiMsg.ID;
            newMsg.Type = agiMsg.Type;
            newMsg.Path = agiMsg.Path;
            newMsg.SessionID = agiMsg.SessionID;
            newMsg.SessionKey = agiMsg.SessionKey;
            newMsg.Data = agiMsg.Data;
            newMsg.Flags = agiMsg.Flags;

            switch (newMsg.Type)
            {
                case "tput":
                    xmppManager.world.agi.tput(newMsg);
                    break;
                case "rput":
                    xmppManager.world.agi.rput(newMsg);
                    break;
                case "tget":
                    xmppManager.world.agi.tget(newMsg);
                    break;
                case "rget":
                    xmppManager.world.agi.rget(newMsg);
                    break;
                case "tattach":
                    xmppManager.world.agi.tattach(newMsg);
                    break;
                case "rattach":
                    xmppManager.world.agi.rattach(newMsg);
                    break;
                case "tremove":
                    xmppManager.world.agi.tremove(newMsg);
                    break;
                case "rremove":
                    xmppManager.world.agi.rremove(newMsg);
                    break;
                case "tflush":
                    xmppManager.world.agi.tflush(newMsg);
                    break;
                case "rflush":
                    xmppManager.world.agi.rflush(newMsg);
                    break;
            }
        }

        if (msg.Body != null)
        {
             messages newMsg = new messages();
            newMsg.body = msg.Body;
            newMsg.from = msg.From.User;

            int count = 0;

            while (chats.Count != 0 && count < chats.Count)
            {
                if (chats.ElementAt(count).chatWith.userID == msg.From.User)
                {
                    chats.ElementAt(count).msgChain.Add(newMsg);
                    return;
                }
                count++;
            }

            chat newchat = new chat();
            newchat.msgChain.Add(newMsg);
            newchat.chatWith.userID = msg.From.User.ToString();
            chats.Add(newchat);
            Console.WriteLine(newMsg.body.ToString());
        }
    }