On 7/23/07, jamie <[EMAIL PROTECTED]> wrote:
On Mon, 2007-07-23 at 01:41 +0200, Marcus Fritzsch wrote:
> As I now can search my ~/.purple chatlogs i tried it with
> tracker-search from my loved zsh and found it being buggy. The same
> holds for tracker-files and tracker-query. I am preparing a patch but
> I am not sure if we want to commit this before release.
>
> Another issue, the command line tools tracker-files and
> tracker-meta-folder do not behave consistently regarding command line
> options and --help.
>
> Yet another one, I think a better name for tracker-meta-folder would
> be tracker-directory-meta or something alike ;)
>
> So, shall I fix the service issues? Someone wants to take care of the
> command line behavior as that's not well known by myself.
>

fixing the service issues should be trivial so pls go ahead - leave the
rest til later

OK, here it is.

* converted strcasecmp to g_ascii_strcasecmp in tracker_service_name_to_type
* added an extra test for "Other" to spit out a warning about unknown
service (module specific, not in tracker_service_name_to_type).

Regarding the tracker.c change I tested it with t-s-t and it showed
normal behaviour.

Marcus
diff --git a/src/libtracker/tracker-files.c b/src/libtracker/tracker-files.c
index e298074..8ccb42d 100644
--- a/src/libtracker/tracker-files.c
+++ b/src/libtracker/tracker-files.c
@@ -27,26 +27,6 @@
 #define USAGE "usage: \ntracker-files -s ServiceType\t: Gets files with ServiceType (Documents, Music, Images, Videos, Text, Development, Other)\ntracker-files -m Mime1 [Mime2...] : Get all files that match one of the specified mime types\n"
 
 
-static ServiceType
-get_service_type (const char* service)
-{
-	if (g_ascii_strcasecmp (service, "Documents") ==0) {
-		return SERVICE_DOCUMENTS;
-	} else 	if (g_ascii_strcasecmp (service, "Music") ==0) {
-		return SERVICE_MUSIC;
-	} else 	if (g_ascii_strcasecmp (service, "Images") ==0) {
-		return SERVICE_IMAGES;
-	} else 	if (g_ascii_strcasecmp (service, "Videos") ==0) {
-		return SERVICE_VIDEOS;
-	} else 	if (g_ascii_strcasecmp (service, "Text") ==0) {
-		return SERVICE_TEXT_FILES;
-	} else 	if (g_ascii_strcasecmp (service, "Development") ==0) {
-		return SERVICE_DEVELOPMENT_FILES;
-	} else {
-		return SERVICE_OTHER_FILES;
-	}
-}
-
 
 int
 main (int argc, char **argv) 
@@ -78,7 +58,7 @@ main (int argc, char **argv)
 			return 1;
 		} else {
 
-			type = get_service_type (argv[2]);
+			type = tracker_service_name_to_type (argv[2]);
 
 			char **array = NULL;
 
diff --git a/src/libtracker/tracker-query.c b/src/libtracker/tracker-query.c
index 99d132b..01cfd62 100644
--- a/src/libtracker/tracker-query.c
+++ b/src/libtracker/tracker-query.c
@@ -124,23 +124,13 @@ main (int argc, char **argv)
 
 	if (!service) {
 		type = SERVICE_FILES;
-	} else if (g_ascii_strcasecmp (service, "Documents") == 0) {
-		type = SERVICE_DOCUMENTS;
-	} else if (g_ascii_strcasecmp (service, "Music") == 0) {
-		type = SERVICE_MUSIC;
-	} else if (g_ascii_strcasecmp (service, "Images") == 0) {
-		type = SERVICE_IMAGES;
-	} else if (g_ascii_strcasecmp (service, "Videos") == 0) {
-		type = SERVICE_VIDEOS;
-	} else if (g_ascii_strcasecmp (service, "Text") == 0) {
-		type = SERVICE_TEXT_FILES;
-	} else if (g_ascii_strcasecmp (service, "Development") == 0) {
-		type = SERVICE_DEVELOPMENT_FILES;
 	} else {
-		g_printerr ("service not recognized, searching in Other Files...\n");
-		type = SERVICE_OTHER_FILES;
-	}
+		type = tracker_service_name_to_type (service);
 
+		if (type == SERVICE_OTHER_FILES && g_ascii_strcasecmp (service, "Other")) {
+			g_printerr ("service not recognized, searching in Other Files...\n");
+		}
+	}
 	
 	char *str_path = realpath_in_utf8 (fields[0]);
 
diff --git a/src/libtracker/tracker-search.c b/src/libtracker/tracker-search.c
index 5bb23a3..d377100 100644
--- a/src/libtracker/tracker-search.c
+++ b/src/libtracker/tracker-search.c
@@ -140,25 +140,12 @@ main (int argc, char **argv)
 
 	if (!service) {
 		type = SERVICE_FILES;
-	} else if (g_ascii_strcasecmp (service, "Documents") == 0) {
-		type = SERVICE_DOCUMENTS;
-	} else if (g_ascii_strcasecmp (service, "Emails") == 0) {
-		type = SERVICE_EMAILS;
-	} else if (g_ascii_strcasecmp (service, "Attachments") == 0) {
-		type = SERVICE_EMAILATTACHMENTS;
-	} else if (g_ascii_strcasecmp (service, "Music") == 0) {
-		type = SERVICE_MUSIC;
-	} else if (g_ascii_strcasecmp (service, "Images") == 0) {
-		type = SERVICE_IMAGES;
-	} else if (g_ascii_strcasecmp (service, "Videos") == 0) {
-		type = SERVICE_VIDEOS;
-	} else if (g_ascii_strcasecmp (service, "Text") == 0) {
-		type = SERVICE_TEXT_FILES;
-	} else if (g_ascii_strcasecmp (service, "Development") == 0) {
-		type = SERVICE_DEVELOPMENT_FILES;
 	} else {
-		g_printerr (_("Service not recognized, searching in Other Files...\n"));
-		type = SERVICE_OTHER_FILES;
+		type = tracker_service_name_to_type (service);
+
+		if (type == SERVICE_OTHER_FILES && g_ascii_strcasecmp (service, "Other")) {
+			g_printerr (_("Service not recognized, searching in Other Files...\n"));
+		}
 	}
 
 	search = g_strjoinv (" ", terms);
diff --git a/src/libtracker/tracker.c b/src/libtracker/tracker.c
index 54193a5..7ce62c1 100644
--- a/src/libtracker/tracker.c
+++ b/src/libtracker/tracker.c
@@ -19,6 +19,7 @@
 
 #include "tracker.h"
 #include <string.h>
+
 #define TRACKER_SERVICE                 "org.freedesktop.Tracker"
 #define TRACKER_OBJECT			"/org/freedesktop/tracker"
 #define TRACKER_INTERFACE		"org.freedesktop.Tracker"
@@ -120,15 +121,14 @@ tracker_service_name_to_type (const char *service)
 
 	for (st=tracker_service_types; *st; st++) {
 
-		if (strcasecmp (service, *st) == 0) {
+		if (g_ascii_strcasecmp (service, *st) == 0) {
 			return i;
 		}
 
 		i++;
 	}
 
-
-	return 0;
+	return SERVICE_OTHER_FILES;
 }
 
 
_______________________________________________
tracker-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/tracker-list

Reply via email to