示例#1
0
        /// <summary>
        /// Retrieving all Privacy Lists
        /// </summary>
        /// <param name="cb">Callback for the server result</param>
        /// <param name="cbArg">Callback arguments for the result when needed</param>
        public void GetLists(IqCB cb, object cbArg)
        {
            /*
             * Example: Client requests names of privacy lists from server:
             *
             * <iq from='[email protected]/orchard' type='get' id='getlist1'>
             * <query xmlns='jabber:iq:privacy'/>
             * </iq>
             *
             * Example: Server sends names of privacy lists to client, preceded by active list and default list:
             *
             * <iq type='result' id='getlist1' to='[email protected]/orchard'>
             * <query xmlns='jabber:iq:privacy'>
             * <active name='private'/>
             * <default name='public'/>
             * <list name='public'/>
             * <list name='private'/>
             * <list name='special'/>
             * </query>
             * </iq>
             *
             */

            var pIq = new PrivacyIq();

            pIq.Type = Client.IQType.Get;

            this.SendStanza(pIq, cb, cbArg);
        }
示例#2
0
        /// <summary>
        /// Requests a privacy list from the server by its name
        /// </summary>
        /// <param name="name">name of the privacy list to retrieve</param>
        /// <param name="cb">Callback for the server result</param>
        /// <param name="cbArg">Callback arguments for the result when needed</param>
        public void GetList(string name, IqCB cb, object cbArg)
        {
            /*
             * Example: Client requests a privacy list from server:
             *
             * <iq from='[email protected]/orchard' type='get' id='getlist2'>
             * <query xmlns='jabber:iq:privacy'>
             * <list name='public'/>
             * </query>
             * </iq>
             *
             * Example: Server sends a privacy list to client:
             *
             * <iq type='result' id='getlist2' to='[email protected]/orchard'>
             * <query xmlns='jabber:iq:privacy'>
             * <list name='public'>
             * <item type='jid'
             *  value='*****@*****.**'
             *  action='deny'
             *  order='1'/>
             * <item action='allow' order='2'/>
             * </list>
             * </query>
             * </iq>
             *
             */

            var pIq = new PrivacyIq();

            pIq.Type = Client.IQType.Get;
            pIq.Query.AddList(new List(name));

            this.SendStanza(pIq, cb, cbArg);
        }
示例#3
0
        /// <summary>
        /// Decline the use of any active list
        /// </summary>
        /// <param name="cb">Callback for the server result</param>
        /// <param name="cbArg">Callback arguments for the result when needed</param>
        public void DeclineActiveList(IqCB cb, object cbArg)
        {
            /*
             * In order to decline the use of any active list, the connected resource MUST send an empty <active/> element
             * with no 'name' attribute.
             *
             * Example: Client declines the use of active lists:
             *
             * <iq from='[email protected]/orchard' type='set' id='active3'>
             * <query xmlns='jabber:iq:privacy'>
             * <active/>
             * </query>
             * </iq>
             *
             * Example: Server acknowledges success of declining any active list:
             *
             * <iq type='result' id='active3' to='[email protected]/orchard'/>
             */

            var pIq = new PrivacyIq();

            pIq.Type         = Client.IQType.Set;
            pIq.Query.Active = new Active();

            this.SendStanza(pIq, cb, cbArg);
        }
示例#4
0
        /// <summary>
        /// Decline the use of the default list
        /// </summary>
        /// <param name="cb">Callback for the server result</param>
        /// <param name="cbArg">Callback arguments for the result when needed</param>
        public void DeclineDefaultList(IqCB cb, object cbArg)
        {
            var pIq = new PrivacyIq();

            pIq.Type          = Client.IQType.Set;
            pIq.Query.Default = new Default();

            this.SendStanza(pIq, cb, cbArg);
        }
示例#5
0
        /// <summary>
        /// Change the default list
        /// </summary>
        /// <param name="name">name of the new default list</param>
        /// <param name="cb">Callback for the server result</param>
        /// <param name="cbArg">Callback arguments for the result when needed</param>
        public void ChangeDefaultList(string name, IqCB cb, object cbArg)
        {
            var pIq = new PrivacyIq();

            pIq.Type          = Client.IQType.Set;
            pIq.Query.Default = new Default(name);

            this.SendStanza(pIq, cb, cbArg);
        }
示例#6
0
        /// <summary>
        /// Remove a privacy list
        /// </summary>
        /// <param name="name">name of the privacy list to remove</param>
        /// <param name="cb">Callback for the server result</param>
        /// <param name="cbArg">Callback arguments for the result when needed</param>
        public void RemoveList(string name, IqCB cb, object cbArg)
        {
            var pIq = new PrivacyIq();

            pIq.Type = Client.IQType.Set;
            pIq.Query.AddList(new List(name));

            this.SendStanza(pIq, cb, cbArg);
        }
示例#7
0
 /// <summary>
 /// Sends a PrivacyIq over the active connection
 /// </summary>
 /// <param name="pIq"></param>
 /// <param name="cb"></param>
 /// <param name="cbArg"></param>
 private void SendStanza(PrivacyIq pIq, IqCB cb, object cbArg)
 {
     if (cb == null)
     {
         this.m_connection.Send(pIq);
     }
     else
     {
         this.m_connection.IqGrabber.SendIq(pIq, cb, cbArg);
     }
 }
示例#8
0
        /// <summary>
        /// Update the list with the given name and rules.
        /// </summary>
        /// <remarks>
        /// Specify the desired changes to the list by including all elements/rules in the list
        /// (not the "delta")
        /// </remarks>
        /// <param name="name">name of this list</param>
        /// <param name="rules">rules of this list</param>
        /// <param name="cb">Callback for the server result</param>
        /// <param name="cbArg">Callback arguments for the result when needed</param>
        public void UpdateList(string name, Item[] rules, IqCB cb, object cbArg)
        {
            var pIq = new PrivacyIq();

            pIq.Type = Client.IQType.Set;

            // create a new list with the given name
            var list = new List(name);

            list.AddItems(rules);
            // add the list to the query
            pIq.Query.AddList(list);

            this.SendStanza(pIq, cb, cbArg);
        }
示例#9
0
        /// <summary>
        /// Change the active list
        /// </summary>
        /// <param name="name"></param>
        /// <param name="cb">Callback for the server result</param>
        /// <param name="cbArg">Callback arguments for the result when needed</param>
        public void ChangeActiveList(string name, IqCB cb, object cbArg)
        {
            /*
             * Example: Client requests change of active list:
             *
             * <iq from='[email protected]/orchard' type='set' id='active1'>
             * <query xmlns='jabber:iq:privacy'>
             * <active name='special'/>
             * </query>
             * </iq>
             *
             * The server MUST activate and apply the requested list before sending the result back to the client.
             *
             * Example: Server acknowledges success of active list change:
             *
             * <iq type='result' id='active1' to='[email protected]/orchard'/>
             *
             * If the user attempts to set an active list but a list by that name does not exist, the server MUST return an <item-not-found/> stanza error to the user:
             *
             * Example: Client attempts to set a non-existent list as active:
             *
             * <iq to='[email protected]/orchard' type='error' id='active2'>
             * <query xmlns='jabber:iq:privacy'>
             * <active name='The Empty Set'/>
             * </query>
             * <error type='cancel'>
             * <item-not-found
             * xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
             * </error>
             * </iq>
             *
             */

            var pIq = new PrivacyIq();

            pIq.Type         = Client.IQType.Set;
            pIq.Query.Active = new Active(name);

            this.SendStanza(pIq, cb, cbArg);
        }