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 + #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; }