RFC before sending patches for a few FIXMEs



Hi all,

I went through the list of FIXMEs and made a few patches. I would like
your comments on a couple of points :

1/ Where should Dashbord configuration go ? GConf might be the good
solution, being the Gnome standard. I have used this layout :

        apps/dashboard/backends/<backend-name>

<backend-name> being a short substitute for the complete backend name. I
have modified two backends for GConf right now :
- MozillaBookmarksBackend : short name 'mozilla'
- BugzillaBackend : short name 'bugzilla'

What do you think of that? Any comments welcomed.


2/ the MozillaBookmarksBackend author would like to use XPath for the
parsing of the html file. To my (limited !) knowledge, that is not
possible. The bookmarks.html file is not well-formed XML (not being
XHTML compliant). One could write a SGML parser, but I'm not sure it'll
be good performance-wise compared to the regexp used actually.


Thanks,

Clement

PS : Description of each patch :

- bugzilla-backend-patch.diff : adds a gconf key for the choice of the
bugzilla server
- geosites-backend-patch.diff : adds the 2 letter state code for
Mapquest URLs
- manpages-backend-patch.diff : some manpages on my system (Debian) are
symlinks to .gz files, and do not end in .N.gz . This patch skips such
manpages for now. A better one is in the works :)
- mozilla-backend-patch.diff : adds 2 gconf keys for the choice of the
mozilla flavour and the profile name
diff -Nru dashboard/backends/BugzillaBackend.cs dashboard-new/backends/BugzillaBackend.cs
--- dashboard/backends/BugzillaBackend.cs	2004-02-16 08:57:30.000000000 +0100
+++ dashboard-new/backends/BugzillaBackend.cs	2004-02-25 16:18:11.000000000 +0100
@@ -2,8 +2,7 @@
 // backend-bugzilla.cs: A backend which displays bugzilla bugs based
 // on their bug numbers.
 //
-// FIXME: Make the bugzilla server (s) configurable.
-//       Choose good bug colors.
+// FIXME: Choose good bug colors.
 //
 // Nat Friedman <nat nat org>
 //
@@ -15,17 +14,31 @@
 using System.Runtime.InteropServices;
 using System.Net;
 using System.Text.RegularExpressions;
+using Gnome;
 
 namespace Dashboard {
 
 	class BugzillaBackend : BackendSimple {
 
-		private const string bugzilla_host = "http://bugzilla.ximian.com";;
+		private string bugzilla_host = "http://bugzilla.ximian.com";;
 
 		public override bool Startup ()
 		{
 			Name = "Bugzilla";
-
+		
+			GConf.Client client = new GConf.Client ();
+			try {
+				string host = (string) client.Get ("/apps/dashboard/backends/bugzilla/host");
+				if (host != "")
+					bugzilla_host = host;
+				else
+					Console.WriteLine ("The GConf Bugzilla host key is empty !");
+			}
+			catch (GConf.NoSuchKeyException) {
+				client.Set ("/apps/dashboard/backends/bugzilla/host","http://bugzilla.ximian.com";);
+				Console.WriteLine ("Setting default Bugzilla host");
+			}
+			
 			this.SubscribeToClues ("bugzilla");
 			this.Initialized = true;
 
diff -Nru dashboard/backends/Makefile.am dashboard-new/backends/Makefile.am
--- dashboard/backends/Makefile.am	2004-02-25 08:43:10.000000000 +0100
+++ dashboard-new/backends/Makefile.am	2004-02-25 16:18:04.000000000 +0100
@@ -86,6 +86,9 @@
 EvolutionMailBackend.dll: EvolutionMailBackend.cs $(dashboard_exe)
 	$(CSC) $(LIBFLAGS) -out:EvolutionMailBackend.dll $(srcdir)/EvolutionMailBackend.cs -r:../util/evolution/evolution.dll -r:gconf-sharp
 
+BugzillaBackend.dll: BugzillaBackend.cs $(dashboard_exe)
+	$(CSC) $(LIBFLAGS) -out:BugzillaBackend.dll $(srcdir)/BugzillaBackend.cs -r:gconf-sharp
+
 GoogleBackend.dll: GoogleBackend.cs $(dashboard_exe)
 	$(CSC) $(LIBFLAGS) -out:GoogleBackend.dll $(srcdir)/GoogleBackend.cs -r:../util/webservices/GoogleSearchService.dll
 
diff -Nru dashboard/backends/GeoSitesBackend.cs dashboard-new/backends/GeoSitesBackend.cs
--- dashboard/backends/GeoSitesBackend.cs	2004-02-17 04:06:06.000000000 +0100
+++ dashboard-new/backends/GeoSitesBackend.cs	2004-02-26 14:13:20.000000000 +0100
@@ -21,12 +21,30 @@
 	class GeoSites : Backend {
 
 		private Gazetteer gazetteer;
+		private Hashtable us_states;
 
 		public override bool Startup ()
 		{
 			Console.WriteLine ("GeoSites backend starting");
 			Name = "GeoSites";
 
+			Assembly assembly = Assembly.GetExecutingAssembly ();
+			System.IO.Stream s = assembly.GetManifestResourceStream ("us_abbr_states.txt");
+		
+			us_states = new Hashtable (67);
+			StreamReader sr = new StreamReader (s);
+
+			string l = sr.ReadLine ();
+
+			while(l != null)
+			{
+				string [] fields = l.Split ('\t');
+				us_states.Add (fields [0], fields [1]);
+				l = sr.ReadLine ();
+			}
+
+			s.Close ();	
+
 			this.SubscribeToClues ("latlong");
 			this.Initialized = true;
 
@@ -51,7 +69,7 @@
 
 			int intlat = (int) dlat;
 			int intlng = (int) dlng;
-
+			
 			Point p = gazetteer.NearestCity (dlat, dlng);
 			if (p == null)
 				return null;
@@ -64,19 +82,19 @@
 			String vicinityurl = String.Format("http://www.vicinity.com/myblast/map.mb?CMD=LFILL&CT={0}:{1}:90000";, lat, lng);
 			match ["MapBlast"] = vicinityurl;
 
+			String mapquesturl = "http://www.mapquest.com/maps/map.adp?city="; + HttpUtility.UrlEncode (p.City);
+
 			// yawn, special case for mapquest
 			if (p.Country == "United States of America")
 			{
 				p.Country = "United States";
+				mapquesturl +=  "&state=" + HttpUtility.UrlEncode ((string)us_states [p.Adminregion]);
 			}
+			else
+				mapquesturl +=  "&state=" + HttpUtility.UrlEncode (p.Adminregion);
+
+			mapquesturl += 	"&country=" + HttpUtility.UrlEncode (p.Country) + "&zoom=5";
 
-			// FIXME: MapQuest requires the state name as a two
-			// letter code where the US is concerned.
-			String mapquesturl = String.Format (
-					"http://www.mapquest.com/maps/map.adp?city={0}&state={1}&country={2}&zoom=5";,
-					HttpUtility.UrlEncode(p.City),
-					HttpUtility.UrlEncode(p.Adminregion),
-					HttpUtility.UrlEncode(p.Country));
 			match ["MapQuest"] = mapquesturl;
 			
 			// yawn, special case for wunderground
diff -Nru dashboard/backends/Makefile.am dashboard-new/backends/Makefile.am
--- dashboard/backends/Makefile.am	2004-02-25 08:43:10.000000000 +0100
+++ dashboard-new/backends/Makefile.am	2004-02-26 14:14:54.000000000 +0100
@@ -78,7 +78,7 @@
 	$(CSC) $(LIBFLAGS) -out:HTMLIndexBackend.dll $(srcdir)/HTMLIndexBackend.cs -r:../index/index-manager.dll
 
 GeoSitesBackend.dll: GeoSitesBackend.cs $(dashboard_exe)
-	$(CSC) $(LIBFLAGS) -out:GeoSitesBackend.dll $(srcdir)/GeoSitesBackend.cs -r:../util/geo/geo.dll
+	$(CSC) $(LIBFLAGS) -out:GeoSitesBackend.dll $(srcdir)/GeoSitesBackend.cs -r:../util/geo/geo.dll -resource:us_abbr_states.txt
 
 ManPagesBackend.dll: ManPagesBackend.cs $(dashboard_exe)
 	$(CSC) $(LIBFLAGS) -out:ManPagesBackend.dll $(srcdir)/ManPagesBackend.cs -r:ICSharpCode.SharpZipLib
diff -Nru dashboard/backends/us_abbr_states.txt dashboard-new/backends/us_abbr_states.txt
--- dashboard/backends/us_abbr_states.txt	1970-01-01 01:00:00.000000000 +0100
+++ dashboard-new/backends/us_abbr_states.txt	2004-02-26 14:11:14.000000000 +0100
@@ -0,0 +1,65 @@
+Alabama	AL
+Alaska	AK
+American Samoa	AS
+Arizona	AZ
+Arkansas	AR
+California	CA
+Colorado	CO
+Connecticut	CT
+Delaware	DE
+District of Columbia	DC
+Federated States of Micronesia	FM
+Florida	FL
+Georgia	GA
+Guam	GU
+Hawaii	HI
+Idaho	ID
+Illinois	IL
+Indiana	IN
+Iowa	IA
+Kansas	KS
+Kentucky	KY
+Louisiana	LA
+Maine	ME
+Marshall Islands	MH
+Maryland	MD
+Massachusetts	MA
+Michigan	MI
+Minnesota	MN
+Mississippi	MS
+Missouri	MO
+Montana	MT
+Nebraska	NE
+Nevada	NV
+New Hampshire	NH
+New Jersey	NJ
+New Mexico	NM
+New York	NY
+North Carolina	NC
+North Dakota	ND
+Northern Mariana Islands	MP
+Ohio	OH
+Oklahoma	OK
+Oregon	OR
+Palau	PW
+Pennsylvania	PA
+Puerto Rico	PR
+Rhode Island	RI
+South Carolina	SC
+South Dakota	SD
+Tennessee	TN
+Texas	TX
+Utah	UT
+Vermont	VT
+Virgin Islands	VI
+Virginia	VA
+Washington	WA
+West Virginia	WV
+Wisconsin	WI
+Wyoming	WY
+Armed Forces Africa	AE
+Armed Forces Americas	AA
+Armed Forces Canada	AE
+Armed Forces Europe	AE
+Armed Forces Middle East	AE
+Armed Forces Pacific	AP
diff -Nru dashboard/backends/ManPagesBackend.cs dashboard-new/backends/ManPagesBackend.cs
--- dashboard/backends/ManPagesBackend.cs	2004-02-20 02:44:00.000000000 +0100
+++ dashboard-new/backends/ManPagesBackend.cs	2004-02-25 16:16:25.000000000 +0100
@@ -63,9 +63,14 @@
 
 						ManPage mp = new ManPage ();
 						mp.path       = man_line;
-						mp.identifier = filename.Substring (0, filename.IndexOf ('.'));
-						mp.basename   = filename.Substring (0, filename.LastIndexOf ('.'));
-						mp.section    = filename.Substring (filename.IndexOf ('.') + 1, 1);
+						try {
+							mp.identifier = filename.Substring (0, filename.IndexOf ('.'));
+							mp.basename   = filename.Substring (0, filename.LastIndexOf ('.'));
+							mp.section    = filename.Substring (filename.IndexOf ('.') + 1, 1);
+						}
+						catch (System.ArgumentOutOfRangeException) {
+							continue;
+						}
 
 						manpages.Add (mp);
 					}
diff -Nru dashboard/backends/Makefile.am dashboard-new/backends/Makefile.am
--- dashboard/backends/Makefile.am	2004-02-25 08:43:10.000000000 +0100
+++ dashboard-new/backends/Makefile.am	2004-02-26 14:19:47.000000000 +0100
@@ -86,6 +86,9 @@
 EvolutionMailBackend.dll: EvolutionMailBackend.cs $(dashboard_exe)
 	$(CSC) $(LIBFLAGS) -out:EvolutionMailBackend.dll $(srcdir)/EvolutionMailBackend.cs -r:../util/evolution/evolution.dll -r:gconf-sharp
 
+MozillaBookmarksBackend.dll: MozillaBookmarksBackend.cs $(dashboard_exe)
+	$(CSC) $(LIBFLAGS) -out:MozillaBookmarksBackend.dll $(srcdir)/MozillaBookmarksBackend.cs -r:gconf-sharp
+
 GoogleBackend.dll: GoogleBackend.cs $(dashboard_exe)
 	$(CSC) $(LIBFLAGS) -out:GoogleBackend.dll $(srcdir)/GoogleBackend.cs -r:../util/webservices/GoogleSearchService.dll
 
diff -Nru dashboard/backends/MozillaBookmarksBackend.cs dashboard-new/backends/MozillaBookmarksBackend.cs
--- dashboard/backends/MozillaBookmarksBackend.cs	2004-02-20 02:44:00.000000000 +0100
+++ dashboard-new/backends/MozillaBookmarksBackend.cs	2004-02-26 14:20:29.000000000 +0100
@@ -27,8 +27,6 @@
 //
 //read the Mozilla or Thunderbird bookmarks
 
-//FIXME: application directory and profile should not be "hard coded".
-
 using System;
 using System.IO;
 using System.Web;
@@ -39,8 +37,8 @@
 
 	class MozillaBookmarks : BackendSimple {
 
-		const string browser_dirname = ".phoenix";
-		const string profile_name = "default";
+		private string browser_dirname = ".phoenix";
+		private string profile_name = "default";
 
 		ArrayList bookmarks = new ArrayList (); 
 
@@ -51,6 +49,31 @@
 			string home_dir = Environment.GetEnvironmentVariable ("HOME");
 			string path;
 
+			GConf.Client client = new GConf.Client ();
+                        try {
+                                string dirname = (string) client.Get ("/apps/dashboard/backends/mozilla/browser_dirname");
+                                if (dirname != "")
+                                        browser_dirname = dirname;
+                                else
+                                        Console.WriteLine ("The GConf Mozilla browser_dirname key is empty !");
+                        }
+                        catch (GConf.NoSuchKeyException) {
+                                client.Set ("/apps/dashboard/backends/mozilla/browser_dirname",".phoenix");
+                                Console.WriteLine ("Setting default Mozilla browser_dirname");
+                        }
+
+                        try {
+                                string profile = (string) client.Get ("/apps/dashboard/backends/mozilla/profile");
+                                if (profile != "")
+                                        profile_name = profile;
+                                else
+                                        Console.WriteLine ("The GConf Mozilla profile key is empty !");
+                        }
+                        catch (GConf.NoSuchKeyException) {
+                                client.Set ("/apps/dashboard/backends/mozilla/profile","default");
+                                Console.WriteLine ("Setting default Mozilla profile");
+                        }
+
 			try {
 				path = Path.Combine (Path.Combine (home_dir, browser_dirname), profile_name);
 


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