Exemple #1
0
 private void deleteToolStripMenuItem_Click(object sender, System.EventArgs e)
 {
     if (listContacts.SelectedItems.Count > 0)
     {
         var item = listContacts.SelectedItems[0];
         var rm   = new RosterManager(xmppClient);
         Jid jid  = item.Name;
         rm.Remove(jid);
     }
 }
Exemple #2
0
        public void Remove(string jid)
        {
            RosterManager rm = new RosterManager(this.xmppClient);

            rm.Remove(jid);
            return;

            /*
             * pubsubManager.Unsubscribe("", "urn:xmpp:openpgp:0", jid, delegate {
             * presenceManager.Unsubscribe(jid);
             *
             * RosterManager rm = new RosterManager(this.xmppClient);
             * rm.Remove(jid);
             * });
             */
        }
Exemple #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);
                        }
                    }
                }
            }
        }
Exemple #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);
                    }
                }
            }
        }
Exemple #5
0
 private void deleteToolStripMenuItem_Click(object sender, System.EventArgs e)
 {
     if (listContacts.SelectedItems.Count > 0)
     {
         var item = listContacts.SelectedItems[0];
         var rm = new RosterManager(xmppClient);
         Jid jid = item.Name;
         rm.Remove(jid);
     }
 }