Re: Inital Deb Filter



Ok, sorry It's been so long (boo Comcast) but here's the .deb filter
with most of the changes we talked about. Some of the formatting stuff
in HACKING wasn't super clear because of the odd syntax of this
filter, if I missed anything else, please point it out, and I will be
more than happy to fix it.

I also added a 'Package' tile for beagle-search. At the moment it
doesn't display much extra, but it can easily be configured to show
dependencies and the like. I was thinking about adding an 'Install'
option in the context menu any thoughts on that?

This should be all you need to test it, I can't figure out how to get
cvs to include new files in the diff, if anyone knows and wants to
share, that would make this easier.

Otherwise, I await your critique.

--Kevin Kubasik

On 4/4/06, Kevin Kubasik <kevin kubasik net> wrote:
> Ok, so I'll keep with more or less the original plan and just make a
> few sections unsearched. I'm thinking on making all the dependencies
> data, author and section unsearched. That sound good?
>
> -Kevin
> On 4/4/06, Joe Shaw <joeshaw novell com> wrote:
> > Hi,
> >
> > On Mon, 2006-04-03 at 18:32 -0400, Kevin Kubasik wrote:
> > > Starting the cleanup now, I'll post an updated version later tonight
> > > or tomorrow morning. My only real question that remains is where to
> > > draw the line for unsearchable keywords.
> >
> > "Unsearched" doesn't mean "unsearchable", it just means that it isn't
> > searched by default.  So anything that you can't imagine someone wanting
> > to type alone into the text field in beagle-search should be marked
> > unsearched.
> >
> > > For example, its easy to say that Version will remain unsearchable, but
> > > what about Section? If I search for 'e-mail client' if i have a
> > > package from the e-mail section, even if its title is
> > > 'mozilla-thunderbird' I would still expect it to be returned.
> >
> > I could perhaps see Version as being something that is useful to type in
> > and search for, so I would tend to make it a keyword.  Section, from
> > your example (non-free/devel) doesn't seem very useful to me.  Maybe
> > there are times when it would be helpful.
> >
> > > And I was just planning on adding description as one big keyword, but
> > > since some descriptions can get rather long, is that an issue?
> >
> > Description looks like valid text to me.  It should be a text field, not
> > a keyword.
> >
> > Joe
> >
> >
> >
>
>
> --
> Cheers,
> Kevin Kubasik
> http://blog.kubasik.net/
>


--
Cheers,
Kevin Kubasik
http://blog.kubasik.net/
Index: Filters/Makefile.am
===================================================================
RCS file: /cvs/gnome/beagle/Filters/Makefile.am,v
retrieving revision 1.67
diff -u -r1.67 Makefile.am
--- Filters/Makefile.am	29 Mar 2006 15:51:04 -0000	1.67
+++ Filters/Makefile.am	16 Apr 2006 04:50:24 -0000
@@ -65,7 +65,8 @@
 	$(srcdir)/FilterEbuild.cs	\
 	$(srcdir)/FilterGif.cs		\
 	$(srcdir)/FilterXslt.cs		\
-	$(srcdir)/FilterRPM.cs
+	$(srcdir)/FilterRPM.cs		\
+	$(srcdir)/FilterDeb.cs		
 
 if ENABLE_GSF_SHARP
 CSFILES += 				\
Index: search/Makefile.am
===================================================================
RCS file: /cvs/gnome/beagle/search/Makefile.am,v
retrieving revision 1.15
diff -u -r1.15 Makefile.am
--- search/Makefile.am	24 Mar 2006 21:55:23 -0000	1.15
+++ search/Makefile.am	16 Apr 2006 04:50:24 -0000
@@ -41,6 +41,7 @@
 	$(srcdir)/Tiles/MailMessage.cs		\
 	$(srcdir)/Tiles/MailAttachment.cs	\
 	$(srcdir)/Tiles/Note.cs			\
+	$(srcdir)/Tiles/Package.cs	\
 	$(srcdir)/Tiles/Presentation.cs		\
 	$(srcdir)/Tiles/RSSFeed.cs		\
 	$(srcdir)/Tiles/Spreadsheet.cs		\
@@ -73,12 +74,13 @@
 	../Util/Util.dll		\
 	../Util/UiUtil.dll		\
 	../images/Images.dll		\
-	../BeagleClient/Beagle.dll
+	../BeagleClient/Beagle.dll	\
+	../beagled/BeagleDaemonLib.dll
 
 ASSEMBLIES =				\
 	$(BEAGLE_UI_LIBS)		\
 	$(LOCAL_ASSEMBLIES:%=-r:%)	\
-	-r:Mono.Posix
+	-r:Mono.Posix 
 
 Search.exe: $(CSFILES) $(TILES) $(PAGES) $(TRAY) $(LOCAL_ASSEMBLIES)
 	$(CSC) -out:$@ $(CSFLAGS) $(CSFILES) $(TILES) $(PAGES) $(TRAY) $(ASSEMBLIES)
Index: search/Tiles/DetailsPane.cs
===================================================================
RCS file: /cvs/gnome/beagle/search/Tiles/DetailsPane.cs,v
retrieving revision 1.1
diff -u -r1.1 DetailsPane.cs
--- search/Tiles/DetailsPane.cs	23 Feb 2006 19:13:24 -0000	1.1
+++ search/Tiles/DetailsPane.cs	16 Apr 2006 04:50:24 -0000
@@ -115,6 +115,7 @@
 		public void AddLabelPair (string label, string text, uint row, uint column)
 		{
 			AddGrayLabel (label, row, column);
+			text = text.Replace("<font color=\"red\"><b>","").Replace("</b></font>","");
 			AddLabel (text, row, column + 1);
 		}
 


//
// FilterDeb.cs: Extracts basic information from .deb archives
//
// Written By: Kevin Kubasik <kevin kubasik net>
//
using System;
using System.IO;
using System.Diagnostics;

using Beagle.Daemon;
using Beagle.Util;

namespace Beagle.Filters{
	public class FilterDeb : Beagle.Daemon.Filter {
	
	public FilterDeb (){
		AddSupportedFlavor (FilterFlavor.NewFromMimeType ("application/x-deb"));
		SnippetMode = true;
	}
	
	protected override void DoPullProperties (){
	
			SafeProcess pc = new SafeProcess ();
			pc.Arguments = new string [] { "dpkg-deb", "-I", FileInfo.FullName};
			pc.RedirectStandardOutput = true;
			
			try {
				pc.Start ();
			} catch (SafeProcessException e) {
				Log.Warn (e.Message);
				Error ();
				return;
			}

			StreamReader pout = new StreamReader(pc.StandardOutput);
			string str = null;
			string[] tokens = null;
			string strMetaTag = null;
			char[] splits = {',','|'};
			string[] list = null;
			while ((str = pout.ReadLine ()) != null) {
				strMetaTag = null;
				tokens = str.Split (':');
				if (tokens.Length <= 1) continue;
				switch (tokens[0].Trim()) {
				case "Package":
					AddProp("dc:title",tokens[1]);
					break;
				case "Maintainer":
					list = tokens[1].Split('<');
					AddProp("dc:author",list[0]);
					AddProp("fixme:author_email",list[1].Replace('>',' '));
					break;
				case "Version":
					AddUnsearched("fixme:version",tokens[1]);
					break;
				case "Section":
					AddUnsearched("fixme:section",tokens[1]);
					break;
				case "Architecture":
					AddUnsearched("fixme:arch",tokens[1]);
					break;
				case "Depends":
					list = tokens[1].Split(splits);
					foreach(string s in list)
						AddUnsearched("fixme:dep",s);
					break;
				case "Recommends":
					list = tokens[1].Split(splits);
					foreach(string s in list)
						AddUnsearched("fixme:recommend",s);
					break;
				case "Conflicts":
					list = tokens[1].Split(splits);
					foreach(string s in list)
						AddUnsearched("fixme:conflict",s);
					break;
				case "Replaces":
					list = tokens[1].Split(splits);
					foreach(string s in list)
						AddUnsearched("fixme:replace",s);
					break;
				case "Provides":
					list = tokens[1].Split(splits);
					foreach(string s in list)
						AddUnsearched("fixme:provide",s);
					break;
				case "Installed-Size":
					AddUnsearched("fixme:size",tokens[1]);
					break;
				case "Description":
					AppendText(tokens[1]);
					AppendStructuralBreak ();
					while ((str = pout.ReadLine ()) != null) {
						if(str.Trim()==".")
							AppendStructuralBreak();
						else
							AppendText(str);
					}
					break;
				}
			}
			pout.Close ();
			pc.Close ();
			Finished ();
		}
	
	private void AddProp (string strMetaTag, string prop){
		AddProperty (Beagle.Property.New (strMetaTag, prop.Trim()));
	}
	
	private void AddKeyword (string strMetaTag, string word){
		AddProperty (Beagle.Property.NewKeyword (strMetaTag, word.Trim()));
	}
	
	private void AddUnsearched (string strMetaTag, string val){
		AddProperty (Beagle.Property.NewUnsearched (strMetaTag, val.Trim()));
	}
	}
}


using System;
using System.Collections;
using System.IO;

using Mono.Unix;

using Beagle.Util;
using Beagle.Daemon;

namespace Search.Tiles {

	public class PackageActivator : TileActivator {

		public PackageActivator () : base ()
		{
			AddSupportedFlavor (new HitFlavor (null, "File", "application/x-deb"));
			AddSupportedFlavor (new HitFlavor (null, "File", "application/x-rpm"));
		}

		public override Tile BuildTile (Beagle.Hit hit, Beagle.Query query)
		{
			return new Package (hit, query);
		}
	}

	public class Package : TileFile {
		Beagle.Hit my_hit;
		Beagle.Query my_query;
		public Package (Beagle.Hit hit, Beagle.Query query) : base (hit, query)
		{
			if( hit["fixme:size"] != null)
				Description = StringFu.FileLengthToString( Convert.ToInt64 ( hit["fixme:size"]+"00"));
			my_hit=hit;
			my_query=query;
		}
		protected override DetailsPane GetDetails ()
		{
			DetailsPane details = new DetailsPane ();
			if( my_hit["dc:title"] != null)
				details.AddLabelPair (Catalog.GetString ("Title:"),
						      my_hit["dc:title"],
						      0, 1);
			details.AddLabelPair (Catalog.GetString ("Last Edited:"),
					      Utils.NiceLongDate (Timestamp),
					      1, 1);
			//FIXME:Internatialize this.
			if (Hit ["dc:author"] != null) {
				details.AddLabelPair ("Packager:",
						      my_hit["dc:author"],
						      0, 3);
			}
			//FIXME:Internatialize this.
			if ( my_hit ["fixme:author_email"] != null) {
				details.AddLabelPair ("Packager Email:",
						      my_hit["fixme:author_email"],
						      1, 3);
			}
			details.AddLabelPair (Catalog.GetString ("Full Path:"),
					      my_hit.Uri.LocalPath,
					      2, 1);
			//FIXME:Internatialize this.
			if(my_hit.FileInfo.Extension == ".rpm" && my_hit["dc:description"] != null){
				string[] temp= new string[my_query.Text.Count];
				my_query.Text.CopyTo(temp,0);
				
				details.AddLabelPair("Description:",
					SnippetFu.GetSnippet(temp , new StringReader(my_hit["dc:description"])),3,1);
				return details;
			}
			details.AddSnippet (3, 1);

			return details;
		}
		
	}
}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]