示例#1
0
		protected void AddSupportedFlavor (FilterFlavor flavor) 
		{
			// Add flavor only when called from RegisterSupportedTypes
			if (supported_flavors == null)
				throw new Exception ("AddSupportedFlavor() should be only called from RegisterSupportedTypes()");

			supported_flavors.Add (flavor);
		}
示例#2
0
        protected void AddSupportedFlavor(FilterFlavor flavor)
        {
            // Add flavor only when called from RegisterSupportedTypes
            if (supported_flavors == null)
            {
                throw new Exception("AddSupportedFlavor() should be only called from RegisterSupportedTypes()");
            }

            supported_flavors.Add(flavor);
        }
示例#3
0
            // flav [larger wt] < flav [smaller wt]
            // for same wt, use hashcode (never return obj1 == obj2 unless they are actually same)
            public int Compare(object obj1, object obj2)
            {
                FilterFlavor flav1 = (FilterFlavor)obj1;
                FilterFlavor flav2 = (FilterFlavor)obj2;

                int ret = flav2.Weight.CompareTo(flav1.Weight);

                if (ret != 0)
                {
                    return(ret);
                }
                else
                {
                    return(obj1.GetHashCode() - obj2.GetHashCode());
                }
            }
示例#4
0
        /////////////////////////////////////////////////////////////////////////


        static private ICollection CreateFilters(Uri uri, string extension, string mime_type)
        {
            SortedList matched_filters_by_flavor = FilterFlavor.NewHashtable();

            foreach (FilterFlavor flavor in FilterFlavor.Flavors)
            {
                if (flavor.IsMatch(uri, extension, mime_type))
                {
                    Filter matched_filter = null;

                    try {
                        matched_filter = (Filter)Activator.CreateInstance((Type)FilterFlavor.FilterTable [flavor]);

                        if (flavor.MimeType != null)
                        {
                            matched_filter.MimeType = flavor.MimeType;
                        }
                        if (flavor.Extension != null)
                        {
                            matched_filter.Extension = flavor.Extension;
                        }
                    } catch (Exception e) {
                        continue;
                    }
                    matched_filters_by_flavor [flavor] = matched_filter;
                }
            }

            if (Debug)
            {
                foreach (DictionaryEntry entry in matched_filters_by_flavor)
                {
                    FilterFlavor flav   = (FilterFlavor)entry.Key;
                    Filter       filter = (Filter)entry.Value;

                    Logger.Log.Debug("Found matching filter: {0}, Weight: {1}", filter, flav.Weight);
                }
            }

            return(matched_filters_by_flavor.Values);
        }
示例#5
0
		protected override void RegisterSupportedTypes ()
		{
			AddSupportedFlavor (FilterFlavor.NewFromMimeType ("message/rfc822"));

			// Add the list of user requested maildir directories
			// This is useful if beagle (xdgmime) does not correctly detect the mimetypes
			// of several maildir files as message/rfc822

			List<string[]> values = Conf.Daemon.GetListOptionValues (Conf.Names.Maildirs);
			if (values == null)
				return;

			foreach (string[] maildir in values) {
				FilterFlavor flavor =
					new FilterFlavor (new Uri (maildir [0] + "/*").ToString (),
							  null, // No meaning of extension for maildir files
							  null,
							  1 /* Should be more than priority of text filter */);
				AddSupportedFlavor (flavor);
			}

			snippet_attachment = Conf.Daemon.GetOption(Conf.Names.EnableEmailAttachmentSnippet, false);
		}