예제 #1
0
 /// <summary>
 /// Initializes a new instance of the PrivacyRule class.
 /// </summary>
 /// <param name="group">The group the privacy rule applies to.</param>
 /// <param name="allow">True to allow entities affected by this rule; Otherwise
 /// false.</param>
 /// <param name="order">The order of the privacy rule.</param>
 /// <param name="granularity">Specifies which kinds of stanzas should be
 /// allowed or blocked, respectively.</param>
 /// <exception cref="ArgumentNullException">The group parameter is null.</exception>
 public GroupPrivacyRule(string group, bool allow, uint order,
     PrivacyGranularity granularity = 0)
     : base(allow, order, granularity)
 {
     group.ThrowIfNull("group");
     Group = group;
 }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the PrivacyRule class.
 /// </summary>
 /// <param name="group">The group the privacy rule applies to.</param>
 /// <param name="allow">True to allow entities affected by this rule; Otherwise
 /// false.</param>
 /// <param name="order">The order of the privacy rule.</param>
 /// <param name="granularity">Specifies which kinds of stanzas should be
 /// allowed or blocked, respectively.</param>
 /// <exception cref="ArgumentNullException">The group parameter is null.</exception>
 public GroupPrivacyRule(string group, bool allow, uint order,
                         PrivacyGranularity granularity = 0)
     : base(allow, order, granularity)
 {
     group.ThrowIfNull("group");
     Group = group;
 }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the PrivacyRule class.
 /// </summary>
 /// <param name="jid">The JID the privacy rule applies to.</param>
 /// <param name="allow">True to allow entities affected by this rule; Otherwise
 /// false.</param>
 /// <param name="order">The order of the privacy rule.</param>
 /// <param name="granularity">Specifies which kinds of stanzas should be
 /// allowed or blocked, respectively.</param>
 /// <exception cref="ArgumentNullException">The jid parameter is null.</exception>
 public JidPrivacyRule(Jid jid, bool allow, uint order,
                       PrivacyGranularity granularity = 0)
     : base(allow, order, granularity)
 {
     jid.ThrowIfNull("jid");
     Jid = jid;
 }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the PrivacyRule class.
 /// </summary>
 /// <param name="jid">The JID the privacy rule applies to.</param>
 /// <param name="allow">True to allow entities affected by this rule; Otherwise
 /// false.</param>
 /// <param name="order">The order of the privacy rule.</param>
 /// <param name="granularity">Specifies which kinds of stanzas should be
 /// allowed or blocked, respectively.</param>
 /// <exception cref="ArgumentNullException">The jid parameter is null.</exception>
 public JidPrivacyRule(Jid jid, bool allow, uint order,
     PrivacyGranularity granularity = 0)
     : base(allow, order, granularity)
 {
     jid.ThrowIfNull("jid");
     Jid = jid;
 }
예제 #5
0
        private PrivacyRule ParsePrivacyItem(XmlElement item)
        {
            item.ThrowIfNull <XmlElement>("item");
            bool allow = item.GetAttribute("action") == "allow";
            uint order = uint.Parse(item.GetAttribute("order"));
            PrivacyGranularity granularity = 0;

            if (item["message"] != null)
            {
                granularity |= PrivacyGranularity.Message;
            }
            if (item["iq"] != null)
            {
                granularity |= PrivacyGranularity.Iq;
            }
            if (item["presence-in"] != null)
            {
                granularity |= PrivacyGranularity.PresenceIn;
            }
            if (item["presence-out"] != null)
            {
                granularity |= PrivacyGranularity.PresenceOut;
            }
            string attribute = item.GetAttribute("type");
            string str2      = item.GetAttribute("value");
            Dictionary <string, SubscriptionState> dictionary2 = new Dictionary <string, SubscriptionState>();

            dictionary2.Add("none", SubscriptionState.None);
            dictionary2.Add("to", SubscriptionState.To);
            dictionary2.Add("from", SubscriptionState.From);
            dictionary2.Add("both", SubscriptionState.Both);
            Dictionary <string, SubscriptionState> dictionary = dictionary2;

            if (string.IsNullOrEmpty(attribute))
            {
                return(new PrivacyRule(allow, order, granularity));
            }
            if (string.IsNullOrEmpty(str2))
            {
                throw new ArgumentException("Missing value attribute.");
            }
            switch (attribute)
            {
            case "jid":
                return(new JidPrivacyRule(new S22.Xmpp.Jid(str2), allow, order, granularity));

            case "group":
                return(new GroupPrivacyRule(str2, allow, order, granularity));

            case "subscription":
                if (!dictionary.ContainsKey(str2))
                {
                    throw new ArgumentException("Invalid value for value attribute: " + str2);
                }
                return(new SubscriptionPrivacyRule(dictionary[str2], allow, order, granularity));
            }
            throw new ArgumentException("The value of the type attribute is invalid: " + attribute);
        }
 /// <summary>
 /// Initializes a new instance of the PrivacyRule class.
 /// </summary>
 /// <param name="state">The subscription state the privacy rule applies
 /// to.</param>
 /// <param name="allow">True to block entities affected by this rule; Otherwise
 /// false.</param>
 /// <param name="order">The order of the privacy rule.</param>
 /// <param name="granularity">Specifies which kinds of stanzas are to be
 /// blocked.</param>
 public SubscriptionPrivacyRule(SubscriptionState state, bool allow, uint order,
     PrivacyGranularity granularity = 0)
     : base(allow, order, granularity)
 {
     SubscriptionState = state;
 }
예제 #7
0
 public JidPrivacyRule(S22.Xmpp.Jid jid, bool allow, uint order, PrivacyGranularity granularity = 0) : base(allow, order, granularity)
 {
     jid.ThrowIfNull <S22.Xmpp.Jid>("jid");
     this.Jid = jid;
 }
예제 #8
0
		/// <summary>
		/// Initializes a new instance of the PrivacyRule class.
		/// </summary>
		/// <param name="allow">True to allow entities affected by this rule; Otherwise
		/// false.</param>
		/// <param name="order">The order of the privacy rule.</param>
		/// <param name="granularity">Specifies which kinds of stanzas should be
		/// blocked.</param>
		public PrivacyRule(bool allow, uint order, PrivacyGranularity granularity = 0) {
			Allow = allow;
			Order = order;
			Granularity = granularity;
		}
 /// <summary>
 /// Initializes a new instance of the PrivacyRule class.
 /// </summary>
 /// <param name="state">The subscription state the privacy rule applies
 /// to.</param>
 /// <param name="allow">True to block entities affected by this rule; Otherwise
 /// false.</param>
 /// <param name="order">The order of the privacy rule.</param>
 /// <param name="granularity">Specifies which kinds of stanzas are to be
 /// blocked.</param>
 public SubscriptionPrivacyRule(SubscriptionState state, bool allow, uint order,
                                PrivacyGranularity granularity = 0)
     : base(allow, order, granularity)
 {
     SubscriptionState = state;
 }
예제 #10
0
 /// <summary>
 /// Initializes a new instance of the PrivacyRule class.
 /// </summary>
 /// <param name="allow">True to allow entities affected by this rule; Otherwise
 /// false.</param>
 /// <param name="order">The order of the privacy rule.</param>
 /// <param name="granularity">Specifies which kinds of stanzas should be
 /// blocked.</param>
 public PrivacyRule(bool allow, uint order, PrivacyGranularity granularity = 0)
 {
     Allow       = allow;
     Order       = order;
     Granularity = granularity;
 }
예제 #11
0
 public PrivacyRule(bool allow, uint order, PrivacyGranularity granularity = 0)
 {
     this.Allow       = allow;
     this.Order       = order;
     this.Granularity = granularity;
 }