예제 #1
0
 /// <summary>
 /// Bloque un identifiant Jabber
 /// </summary>
 /// <param name="jbid">Identifiant Jabber</param>
 public void block(string jbid)
 {
     if (Jabber.xmpp.Authenticated)
     {
         agsXMPP.Jid jid = new agsXMPP.Jid(jbid);
         if (jid != null && jid.ToString() != Jabber.xmpp.MyJID.ToString())
         {
             agsXMPP.protocol.iq.privacy.PrivacyIq piq = new agsXMPP.protocol.iq.privacy.PrivacyIq();
             piq.From = Jabber.xmpp.MyJID;
             piq.Type = agsXMPP.protocol.client.IqType.set;
             agsXMPP.protocol.iq.privacy.List list = new agsXMPP.protocol.iq.privacy.List(Jabber.xmpp.MyJID.Bare.Replace("@", "_").Replace("/", "_").Replace(".", "_"));
             agsXMPP.protocol.iq.privacy.Item item = new agsXMPP.protocol.iq.privacy.Item();
             item.Action = agsXMPP.protocol.iq.privacy.Action.deny;
             item.BlockIncomingPresence = false;
             item.BlockIq               = true;
             item.BlockMessage          = true;
             item.BlockOutgoingPresence = true;
             item.Order  = 1;
             item.Stanza = agsXMPP.protocol.iq.privacy.Stanza.Iq | agsXMPP.protocol.iq.privacy.Stanza.Message | agsXMPP.protocol.iq.privacy.Stanza.OutgoingPresence;
             item.Type   = agsXMPP.protocol.iq.privacy.Type.jid;
             item.Val    = jid.ToString();
             list.AddItem(item);
             piq.Query.AddList(list);
             PrivacyStructure ps = new PrivacyStructure();
             ps.id  = piq.Id;
             ps.jid = jid;
             Jabber.xmpp.IqGrabber.SendIq(piq, new agsXMPP.IqCB(blockResult), ps);
         }
     }
 }
예제 #2
0
        private void unblockResult(object sender, agsXMPP.protocol.client.IQ iq, object data)
        {
            PrivacyStructure ps = (PrivacyStructure)data;

            if (iq.Type == agsXMPP.protocol.client.IqType.result && iq.Id == ps.id)
            {
                if (_blockedJid.Contains(ps.jid.ToString()))
                {
                    _blockedJid.Remove(ps.jid.ToString());
                }
            }
        }
예제 #3
0
 /// <summary>
 /// Bloque un identifiant Jabber
 /// </summary>
 /// <param name="jbid">Identifiant Jabber</param>
 public void block(string jbid)
 {
     if (Jabber.xmpp.Authenticated)
     {
         agsXMPP.Jid jid = new agsXMPP.Jid(jbid);
         if (jid != null && jid.ToString() != Jabber.xmpp.MyJID.ToString())
         {
             agsXMPP.protocol.iq.privacy.PrivacyIq piq = new agsXMPP.protocol.iq.privacy.PrivacyIq();
             piq.From = Jabber.xmpp.MyJID;
             piq.Type = agsXMPP.protocol.client.IqType.set;
             agsXMPP.protocol.iq.privacy.List list = new agsXMPP.protocol.iq.privacy.List(Jabber.xmpp.MyJID.Bare.Replace("@", "_").Replace("/", "_").Replace(".", "_"));
             agsXMPP.protocol.iq.privacy.Item item = new agsXMPP.protocol.iq.privacy.Item();
             item.Action = agsXMPP.protocol.iq.privacy.Action.deny;
             item.BlockIncomingPresence = false;
             item.BlockIq = true;
             item.BlockMessage = true;
             item.BlockOutgoingPresence = true;
             item.Order = 1;
             item.Stanza = agsXMPP.protocol.iq.privacy.Stanza.Iq | agsXMPP.protocol.iq.privacy.Stanza.Message | agsXMPP.protocol.iq.privacy.Stanza.OutgoingPresence;
             item.Type = agsXMPP.protocol.iq.privacy.Type.jid;
             item.Val = jid.ToString();
             list.AddItem(item);
             piq.Query.AddList(list);
             PrivacyStructure ps = new PrivacyStructure();
             ps.id = piq.Id;
             ps.jid = jid;
             Jabber.xmpp.IqGrabber.SendIq(piq, new agsXMPP.IqCB(blockResult), ps);
         }
     }
 }