[maemo-commits] [maemo-commits] r16255 - projects/haf/branches/hildon-thumbnail/daemonize/tests

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Mon Sep 29 13:10:58 EEST 2008
Author: pvanhoof
Date: 2008-09-29 13:10:54 +0300 (Mon, 29 Sep 2008)
New Revision: 16255

Modified:
   projects/haf/branches/hildon-thumbnail/daemonize/tests/Makefile.am
   projects/haf/branches/hildon-thumbnail/daemonize/tests/google-images-art-downloader.vala
Log:
Some various fixes

Modified: projects/haf/branches/hildon-thumbnail/daemonize/tests/Makefile.am
===================================================================
--- projects/haf/branches/hildon-thumbnail/daemonize/tests/Makefile.am	2008-09-29 09:34:23 UTC (rev 16254)
+++ projects/haf/branches/hildon-thumbnail/daemonize/tests/Makefile.am	2008-09-29 10:10:54 UTC (rev 16255)
@@ -45,7 +45,7 @@
 %-glue.h: $(top_srcdir)/tests/%.xml
 	$(DBUSBINDINGTOOL) --mode=glib-server --output=$@ --prefix=$(subst -,_,$*) $^
 
-EXTRA_DIST = $(BUILT_SOURCES) daemon.xml
+EXTRA_DIST = $(BUILT_SOURCES) daemon.xml my.vala.stamp
 
 
 

Modified: projects/haf/branches/hildon-thumbnail/daemonize/tests/google-images-art-downloader.vala
===================================================================
--- projects/haf/branches/hildon-thumbnail/daemonize/tests/google-images-art-downloader.vala	2008-09-29 09:34:23 UTC (rev 16254)
+++ projects/haf/branches/hildon-thumbnail/daemonize/tests/google-images-art-downloader.vala	2008-09-29 10:10:54 UTC (rev 16255)
@@ -7,14 +7,14 @@
 
 public class GoogleImages : Object, Provider {
 	public void Fetch (string artistalbum, string uri) {
-		uint u = 0, hread;
+		uint u = 0, hread = 0;
 		string [] pieces = artistalbum.split (" ", -1);
 		string stitched = "";
 
 		print ("Fetch " + artistalbum + " " + uri + "\n");
 
 		while (pieces[u] != null) {
-			if (u != 1)
+			if (u != 0)
 				stitched += "+";
 			stitched += pieces[u];
 			u++;
@@ -22,10 +22,11 @@
 
 		File google_search = File.new_for_uri ("http://images.google.com/images?q=" + stitched);
 		try {
-			char [] buffer = new char [4000];
+			char [] buffer = new char [40000];
 			string asstring;
 			InputStream stream = google_search.read (null);
-			stream.read_all (buffer, 40000, out hread, null);
+			if (stream != null)
+				stream.read_all (buffer, 40000, out hread, null);
 			buffer[hread] = 0;
 
 			asstring = (string) buffer;
@@ -40,8 +41,27 @@
 					url.append_unichar (found[i]);
 					i++;
 				}
-				
-				print (url.str + "\n");
+
+				string cache_path;
+
+				string cache_dir = Path.build_filename (Environment.get_home_dir(),
+												  ".album_art",
+												  null);
+
+				cache_path = Path.build_filename (Environment.get_home_dir(),
+												  ".album_art",
+												  Checksum.compute_for_string (ChecksumType.MD5, artistalbum.down () + ".jpeg", -1),
+												  null);
+
+				DirUtils.create_with_parents (cache_dir, 0770);
+
+				File online_image = File.new_for_uri (url.str);
+				File cache_image = File.new_for_path (cache_path);
+
+				online_image.copy (cache_image, 
+								   FileCopyFlags.NONE, 
+								   null, 
+								   null);
 			}
 
 		} catch (GLib.Error error) {


More information about the maemo-commits mailing list