Пример #1
0
        private void addToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            var input = new FrmAddUser(_dictContactGroups, true, xmppClient);

            if (input.ShowDialog() == DialogResult.OK)
            {
                _dictContactGroups = input.DictContactGroups;
                var rm  = new RosterManager(xmppClient);
                Jid jid = input.Address;
                rm.Add(jid, input.Name, input.Group);

                var    pm     = new PresenceManager(xmppClient);
                string reason = input.Message;
                pm.Subscribe(jid, reason, input.Name);
            }
        }
Пример #2
0
 private void editToolStripMenuItem_Click(object sender, System.EventArgs e)
 {
     if (listContacts.SelectedItems.Count > 0)
     {
         var item  = listContacts.SelectedItems[0];
         var input = new FrmAddUser(_dictContactGroups, false, xmppClient);
         input.Name    = item.Text;
         input.Address = item.Name;
         input.Group   = item.Group.Header;
         if (input.ShowDialog() == DialogResult.OK)
         {
             var rm  = new RosterManager(xmppClient);
             Jid jid = input.Address;
             rm.Update(jid, input.Name, input.Group);
         }
     }
 }
Пример #3
0
        private void xmppClient_OnPresence(object sender, PresenceEventArgs e)
        {
            DisplayEvent(string.Format("OnPresence\t{0}", e.Presence.From));

            if (e.Presence.Type == PresenceType.Subscribe)
            {
                //presenceManager.ApproveSubscriptionRequest(e.Presence.From);
                var item = listContacts.Items[e.Presence.From.Bare] as RosterListViewItem;
                if (item != null)
                {
                    var pm = new PresenceManager(xmppClient);
                    pm.ApproveSubscriptionRequest(e.Presence.From);
                }
                else
                {
                    var input = new FrmAddUser(_dictContactGroups, true, xmppClient);
                    input.Address = e.Presence.From;
                    if (input.ShowDialog() == DialogResult.OK)
                    {
                        _dictContactGroups = input.DictContactGroups;
                        var rm  = new RosterManager(xmppClient);
                        Jid jid = input.Address;
                        rm.Add(jid, input.Name, input.Group);

                        var pm = new PresenceManager(xmppClient);
                        pm.ApproveSubscriptionRequest(e.Presence.From);
                        //string reason = input.Message;
                        //pm.Subscribe(jid, reason, input.Name);
                    }
                }
            }
            else if (e.Presence.Type == PresenceType.Subscribed)
            {
                var pm = new PresenceManager(xmppClient);
                pm.ApproveSubscriptionRequest(e.Presence.From);
            }
            else if (e.Presence.Type == PresenceType.Unsubscribe)
            {
                var pm = new PresenceManager(xmppClient);
                pm.ApproveSubscriptionRequest(e.Presence.From);
                var rm  = new RosterManager(xmppClient);
                Jid jid = e.Presence.From;
                rm.Remove(jid);
            }
            else if (e.Presence.Type == PresenceType.Unsubscribed)
            {
                var pm = new PresenceManager(xmppClient);
                pm.ApproveSubscriptionRequest(e.Presence.From);
                var rm  = new RosterManager(xmppClient);
                Jid jid = e.Presence.From;
                rm.Remove(jid);
            }
            else
            {
                var item = listContacts.Items[e.Presence.From.Bare] as RosterListViewItem;
                if (item != null)
                {
                    item.ImageIndex = Util.GetRosterImageIndex(e.Presence);
                    string resource = e.Presence.From.Resource;
                    if (e.Presence.Type != PresenceType.Unavailable)
                    {
                        if (!item.Resources.Contains(resource))
                        {
                            item.Resources.Add(resource);
                        }
                    }
                    else
                    {
                        if (item.Resources.Contains(resource))
                        {
                            item.Resources.Remove(resource);
                        }
                    }
                }
            }
        }
Пример #4
0
        private void xmppClient_OnPresence(object sender, PresenceEventArgs e)
        {
            DisplayEvent(string.Format("OnPresence\t{0}", e.Presence.From));

            if (e.Presence.Type == PresenceType.Subscribe)
            {
                //presenceManager.ApproveSubscriptionRequest(e.Presence.From);
                var item = listContacts.Items[e.Presence.From.Bare] as RosterListViewItem;
                if (item != null)
                {
                    var pm = new PresenceManager(xmppClient);
                    pm.ApproveSubscriptionRequest(e.Presence.From);
                }
                else
                {
                    var input = new FrmAddUser(_dictContactGroups, true, xmppClient);
                    input.Address = e.Presence.From;
                    if (input.ShowDialog() == DialogResult.OK)
                    {
                        _dictContactGroups = input.DictContactGroups;
                        var rm = new RosterManager(xmppClient);
                        Jid jid = input.Address;
                        rm.Add(jid, input.Name, input.Group);

                        var pm = new PresenceManager(xmppClient);
                        pm.ApproveSubscriptionRequest(e.Presence.From);
                        //string reason = input.Message;
                        //pm.Subscribe(jid, reason, input.Name);
                    }
                }
            }
            else if (e.Presence.Type == PresenceType.Subscribed)
            {
                var pm = new PresenceManager(xmppClient);
                pm.ApproveSubscriptionRequest(e.Presence.From);
            }
            else if (e.Presence.Type == PresenceType.Unsubscribe)
            {
                var pm = new PresenceManager(xmppClient);
                pm.ApproveSubscriptionRequest(e.Presence.From);
                var rm = new RosterManager(xmppClient);
                Jid jid = e.Presence.From;
                rm.Remove(jid);
            }
            else if (e.Presence.Type == PresenceType.Unsubscribed)
            {
                var pm = new PresenceManager(xmppClient);
                pm.ApproveSubscriptionRequest(e.Presence.From);
                var rm = new RosterManager(xmppClient);
                Jid jid = e.Presence.From;
                rm.Remove(jid);
            }
            else
            {
                var item = listContacts.Items[e.Presence.From.Bare] as RosterListViewItem;
                if (item != null)
                {
                    item.ImageIndex = Util.GetRosterImageIndex(e.Presence);
                    string resource = e.Presence.From.Resource;
                    if (e.Presence.Type != PresenceType.Unavailable)
                    {
                        if (!item.Resources.Contains(resource))
                            item.Resources.Add(resource);
                    }
                    else
                    {
                        if (item.Resources.Contains(resource))
                            item.Resources.Remove(resource);
                    }
                }
            }
        }
Пример #5
0
 private void editToolStripMenuItem_Click(object sender, System.EventArgs e)
 {
     if (listContacts.SelectedItems.Count > 0)
     {
         var item = listContacts.SelectedItems[0];
         var input = new FrmAddUser(_dictContactGroups, false, xmppClient);
         input.Name = item.Text;
         input.Address = item.Name;
         input.Group = item.Group.Header;
         if (input.ShowDialog() == DialogResult.OK)
         {
             var rm = new RosterManager(xmppClient);
             Jid jid = input.Address;
             rm.Update(jid, input.Name, input.Group);
         }
     }
 }
Пример #6
0
        private void addToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            var input = new FrmAddUser(_dictContactGroups, true, xmppClient);
            if (input.ShowDialog() == DialogResult.OK)
            {
                _dictContactGroups = input.DictContactGroups;
                var rm = new RosterManager(xmppClient);
                Jid jid = input.Address;
                rm.Add(jid, input.Name, input.Group);

                var pm = new PresenceManager(xmppClient);
                string reason = input.Message;
                pm.Subscribe(jid, reason, input.Name);
            }
        }