/// <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;
 }
Exemple #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;
 }
Exemple #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;
 }
 /// <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;
 }
Exemple #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;
 }
 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;
 }
Exemple #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;
 }
Exemple #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;
 }
Exemple #11
0
 public PrivacyRule(bool allow, uint order, PrivacyGranularity granularity = 0)
 {
     this.Allow       = allow;
     this.Order       = order;
     this.Granularity = granularity;
 }