Ejemplo n.º 1
0
        protected virtual void XmppClient_OnRosterItem(object sender, Matrix.Xmpp.Roster.RosterEventArgs e)
        {
            List <AppCore.User> uses = LegionUtils.getListJson(appPreferences.getValueKey(AppPreferences.CONTACTS));

            uses.Add(new AppCore.User(e.RosterItem.Jid.Bare, e.RosterItem.Jid.Bare.Split('@')[0]));
            LegionUtils.saveFoundContacts(uses, appPreferences, AppPreferences.CONTACTS);
        }
Ejemplo n.º 2
0
        private void xmppClient_OnRosterItem(object sender, Matrix.Xmpp.Roster.RosterEventArgs e)
        {
            DisplayEvent(string.Format("OnRosterItem\t{0}\t{1}", e.RosterItem.Jid, e.RosterItem.Name));

            if (e.RosterItem.Ask == Matrix.Xmpp.Roster.Ask.Unsubscribe)
            {
            }
            else if (e.RosterItem.Subscription != Subscription.Remove)
            {
                // set a default group name
                string groupname = "Contacts";

                // id the contact has groups get the 1st group. In this example we don't support multiple or nested groups
                // for contacts, but XMPP has support for this.
                if (e.RosterItem.HasGroups)
                {
                    groupname = e.RosterItem.GetGroups()[0];
                }


                if (!_dictContactGroups.ContainsKey(groupname))
                {
                    var newGroup = new ListViewGroup(groupname);
                    _dictContactGroups.Add(groupname, newGroup);
                    listContacts.Groups.Add(newGroup);
                }

                var listGroup = _dictContactGroups[groupname];

                // contact already exists, this is a contact update
                if (_dictContats.ContainsKey(e.RosterItem.Jid))
                {
                    listContacts.Items.RemoveByKey(e.RosterItem.Jid);
                }

                var contract = listContacts.Items.Find(e.RosterItem.Jid, true);
                if (contract.Count() == 0)
                {
                    //var newItem = new ListViewItem(e.RosterItem.Jid, listGroup) {Name = e.RosterItem.Jid};
                    var newItem = new RosterListViewItem(e.RosterItem.Name ?? e.RosterItem.Jid, 0, listGroup)
                    {
                        Name = e.RosterItem.Jid.Bare
                    };
                    newItem.SubItems.AddRange(new[] { "", "" });


                    listContacts.Items.Add(newItem);
                }

                if (contract.Count() > 0)
                {
                    listContacts.Items[listContacts.Items.IndexOf(contract[0])].Text  = e.RosterItem.Name;
                    listContacts.Items[listContacts.Items.IndexOf(contract[0])].Group = listGroup;
                }
            }
            else if (e.RosterItem.Subscription == Subscription.Remove)
            {
                listContacts.Items.RemoveByKey(e.RosterItem.Jid);
            }
        }
Ejemplo n.º 3
0
 void XmppClient_OnRosterItem(object sender, Matrix.Xmpp.Roster.RosterEventArgs e)
 {
     Log.Debug("XmppClient_OnRosterItem");
     if (this.OnRosterItem != null)
     {
         this.OnRosterItem(this, e);
     }
 }
Ejemplo n.º 4
0
        void xmppClient_OnRosterItem(object sender, Matrix.Xmpp.Roster.RosterEventArgs e)
        {
            DisplayEvent("OnRosterItem");

            string uniqueId = Matrix.Util.Hash.Sha1HashHex(e.RosterItem.Jid.Bare);

            Clients.Client(Context.ConnectionId).onRosterItem(uniqueId, e.RosterItem.Jid.Bare, e.RosterItem.Name ?? "");
        }
Ejemplo n.º 5
0
        public void XmppClient_OnRosterItem(object sender, Matrix.Xmpp.Roster.RosterEventArgs e)
        {
            List <AppCore.User> uses = LegionUtils.getListJson(appPreferences.getValueKey(AppPreferences.CONTACTS));

            uses.Add(new AppCore.User(e.RosterItem.Jid.Bare, e.RosterItem.Jid.Bare.Split('@')[0]));
            LegionUtils.saveFoundContacts(uses, appPreferences, AppPreferences.CONTACTS);

            if (context.GetType() == typeof(ContacPhoneActivity))
            {
                ContacPhoneActivity cpa = (ContacPhoneActivity)context;
                cpa.XmppClient_OnRosterItem(sender, e);
            }
        }
Ejemplo n.º 6
0
    // Handle RosterItem event used for fetching contacts
    void xmpp_OnRosterItem(object sender, Matrix.Xmpp.Roster.RosterEventArgs rosterEventArgs)
    {
        UnityEngine.Debug.Log("OnRoasterItem :" + rosterEventArgs.ToString());
        UnityEngine.Debug.Log(rosterEventArgs.RosterItem.Jid);
        UnityEngine.Debug.Log(rosterEventArgs.RosterItem.Name);
        if (ChatItemBeans == null)
        {
            ChatItemBeans = new ArrayList();
        }
        // Don't add if contact is already displayed
        ChatItemBean chatItemBean = new ChatItemBean(rosterEventArgs.RosterItem.Jid, rosterEventArgs.RosterItem.Name, "");

        if (!ChatItemBeans.Contains(chatItemBean))
        {
            ChatItemBeans.Add(chatItemBean);
        }
    }
Ejemplo n.º 7
0
        private void xmppClient_OnRosterItem(object sender, Matrix.Xmpp.Roster.RosterEventArgs e)//จัดการผู้ที่ติดต่อทั้งหมด goupbox
        {
            DisplayEvent(string.Format("รายการชื่อผู้ติดต่อ\t{0}\t{1}", e.RosterItem.Jid, e.RosterItem.Name));

            if (e.RosterItem.Subscription != Subscription.remove)
            {
                // set a default group name
                string groupname = "รายชื่อกลุ่มผู้ติดต่อ";

                // id the contact has groups get the 1st group. In this example we don't support multiple or nested groups
                // for contacts, but XMPP has support for this.
                if (e.RosterItem.HasGroups)
                {
                    groupname = e.RosterItem.GetGroups()[0];
                }

                if (!_dictContactGroups.ContainsKey(groupname))
                {
                    var newGroup = new ListViewGroup(groupname);
                    _dictContactGroups.Add(groupname, newGroup);
                    listContacts.Groups.Add(newGroup);
                }

                var listGroup = _dictContactGroups[groupname];

                // contact already exists, this is a contact update
                if (_dictContats.ContainsKey(e.RosterItem.Jid))
                {
                    listContacts.Items.RemoveByKey(e.RosterItem.Jid);
                }

                //var newItem = new ListViewItem(e.RosterItem.Jid, listGroup) {Name = e.RosterItem.Jid};
                var newItem = new RosterListViewItem(e.RosterItem.Name ?? e.RosterItem.Jid, 0, listGroup)
                {
                    Name = e.RosterItem.Jid.Bare
                };
                newItem.SubItems.AddRange(new[] { "", "" });


                listContacts.Items.Add(newItem);
            }
        }
Ejemplo n.º 8
0
 void xmppClient_OnRosterItem(object sender, Matrix.Xmpp.Roster.RosterEventArgs e)
 {
     //DisplayEvent("OnRosterItem");
     if (e.RosterItem.Subscription != Matrix.Xmpp.Roster.Subscription.Remove && !XmppContactList[Context.ConnectionId].Any(x => x.Bare == e.RosterItem.Jid.Bare))
     {
         string uniqueId = Matrix.Util.Hash.Sha1HashHex(e.RosterItem.Jid.Bare);
         if (XmppContactList.ContainsKey(Context.ConnectionId))
         {
             XmppContactList[Context.ConnectionId].Add(new RosterData
             {
                 uniqueId = uniqueId,
                 Bare     = e.RosterItem.Jid.Bare,
                 Name     = e.RosterItem.Name
             });
         }
         else
         {
             XmppContactList.Add(Context.ConnectionId, new List <RosterData> {
                 new RosterData
                 {
                     uniqueId = uniqueId,
                     Bare     = e.RosterItem.Jid.Bare,
                     Name     = e.RosterItem.Name
                 }
             });
         }
     }
     else
     {
         if (XmppContactList[Context.ConnectionId].Any(x => x.Bare == e.RosterItem.Jid.Bare))
         {
             var deletedRoster = XmppContactList[Context.ConnectionId].First(x => x.Bare == e.RosterItem.Jid.Bare);
             XmppContactList[Context.ConnectionId].Remove(deletedRoster);
         }
     }
     Clients.Client(Context.ConnectionId).onRosterItemReceived(XmppContactList[Context.ConnectionId]);
 }
Ejemplo n.º 9
0
 void client_OnRosterItem(object sender, Matrix.Xmpp.Roster.RosterEventArgs e)
 {
     Console.WriteLine("{0} roster:{1}", m_Name, e.RosterItem);
 }
Ejemplo n.º 10
0
 public void XmppClient_OnRosterItem(object sender, Matrix.Xmpp.Roster.RosterEventArgs e)
 {
     updateListCardUi();
 }