[tracker/libtracker-sparql-porting: 40/46] tracker-utils: Whitespace fixes for tracker-tag.c



commit 37e5ab5cff2943d8dcc1ca339cdb28e9f914379b
Author: Philip Van Hoof <philip codeminded be>
Date:   Fri Aug 6 17:02:16 2010 +0200

    tracker-utils: Whitespace fixes for tracker-tag.c

 src/tracker-utils/tracker-tag.c |  284 +++++++++++++++++++--------------------
 1 files changed, 141 insertions(+), 143 deletions(-)
---
diff --git a/src/tracker-utils/tracker-tag.c b/src/tracker-utils/tracker-tag.c
index ab16bcc..2fa8025 100644
--- a/src/tracker-utils/tracker-tag.c
+++ b/src/tracker-utils/tracker-tag.c
@@ -29,10 +29,10 @@
 
 #include <libtracker-sparql/tracker-sparql.h>
 
-#define ABOUT	  \
+#define ABOUT \
 	"Tracker " PACKAGE_VERSION "\n"
 
-#define LICENSE	  \
+#define LICENSE \
 	"This program is free software and comes without any warranty.\n" \
 	"It is licensed under version 2 or later of the General Public " \
 	"License which can be viewed at:\n" \
@@ -168,9 +168,9 @@ get_fts_string (GStrv    search_words,
 	for (i = 0; i < len; i++) {
 		g_string_append (fts, search_words[i]);
 
-                if (use_asterisk) {
-                        g_string_append_c (fts, '*');
-                }
+		if (use_asterisk) {
+			g_string_append_c (fts, '*');
+		}
 
 		if (i < len - 1) {
 			if (for_regex) {
@@ -315,21 +315,21 @@ result_to_strv (TrackerSparqlCursor *cursor,
 		return NULL;
 	}
 
-        i = 0;
-        count = 0;
+	i = 0;
+	count = 0;
+
+	/* Really no other option here, but we iterate the cursor
+	 * first to get the length.
+	 */
+	while (tracker_sparql_cursor_next (cursor, NULL, NULL)) {
+		count++;
+	}
 
-        /* Really no other option here, but we iterate the cursor
-         * first to get the length.
-         */
-        while (tracker_sparql_cursor_next (cursor, NULL, NULL)) {
-                count++;
-        }
-        
 	strv = g_new0 (gchar *, count + 1);
 
-        tracker_sparql_cursor_rewind (cursor);
+	tracker_sparql_cursor_rewind (cursor);
 
-        while (tracker_sparql_cursor_next (cursor, NULL, NULL)) {
+	while (tracker_sparql_cursor_next (cursor, NULL, NULL)) {
 		const gchar *str;
 
 		str = tracker_sparql_cursor_get_string (cursor, n_col, NULL);
@@ -343,14 +343,14 @@ static void
 get_all_tags_show_tag_id (TrackerSparqlConnection *connection,
                           const gchar             *id)
 {
-        TrackerSparqlCursor *cursor;
+	TrackerSparqlCursor *cursor;
 	GError *error = NULL;
-        gchar *query;
+	gchar *query;
 
 	/* Get files associated */
 	query = g_strdup_printf ("SELECT ?uri WHERE {"
 	                         "  ?urn a rdfs:Resource; "
-				 "  nie:url ?uri ; "
+	                         "  nie:url ?uri ; "
 	                         "  nao:hasTag \"%s\" . "
 	                         "}",
 	                         id);
@@ -360,23 +360,23 @@ get_all_tags_show_tag_id (TrackerSparqlConnection *connection,
 
 	if (error) {
 		g_printerr ("    %s, %s\n",
-                            _("Could not get files related to tag"),
-                            error->message);
+		            _("Could not get files related to tag"),
+		            error->message);
 		g_error_free (error);
 		return;
 	}
 
-        if (!cursor) {
-                g_print ("    %s\n", _("None"));
-                return;
-        }
+	if (!cursor) {
+		g_print ("    %s\n", _("None"));
+		return;
+	}
 
 
-        while (tracker_sparql_cursor_next (cursor, NULL, NULL)) {
+	while (tracker_sparql_cursor_next (cursor, NULL, NULL)) {
 		g_print ("    %s\n", tracker_sparql_cursor_get_string (cursor, 0, NULL));
 	}
 
-        g_object_unref (cursor);
+	g_object_unref (cursor);
 }
 
 static gboolean
@@ -387,7 +387,7 @@ get_all_tags (TrackerSparqlConnection *connection,
               gboolean                 use_or_operator,
               gboolean                 show_files)
 {
-        TrackerSparqlCursor *cursor;
+	TrackerSparqlCursor *cursor;
 	GError *error = NULL;
 	gchar *fts;
 	gchar *query;
@@ -446,53 +446,53 @@ get_all_tags (TrackerSparqlConnection *connection,
 		g_print ("%s\n",
 		         _("No tags were found"));
 	} else {
-                gint count = 0;
+		gint count = 0;
 
-                g_print ("%s:\n", _("Tags (shown by name)"));
+		g_print ("%s:\n", _("Tags (shown by name)"));
 
 		while (tracker_sparql_cursor_next (cursor, NULL, NULL)) {
-                        const gchar *id;
-                        const gchar *tag;
-                        const gchar *description;
-                        const gchar *files;
-                        gint n_files = 0;
-
-                        id = tracker_sparql_cursor_get_string (cursor, 0, NULL);
-                        files = tracker_sparql_cursor_get_string (cursor, 3, NULL);
-                        n_files = atoi (files);
-
-                        tag = tracker_sparql_cursor_get_string (cursor, 1, NULL);
-                        description = tracker_sparql_cursor_get_string (cursor, 2, NULL);
-
-                        if (description && *description == '\0') {
-                                description = NULL;
-                        }
-
-                        g_print ("  %s %s%s%s\n", 
-                                 tag,
-                                 description ? "(" : "",
-                                 description ? description : "",
-                                 description ? ")" : "");
-
-                        if (show_files && n_files > 0) {
-                                get_all_tags_show_tag_id (connection, id);
-                        } else {
-                                g_print ("    %s\n", id);
-                                g_print ("    ");
-                                g_print (g_dngettext (NULL,
-                                                      "%d file",
-                                                      "%d files",
-                                                      n_files),
-                                         n_files);
-                                g_print ("\n");
-                        }
+			const gchar *id;
+			const gchar *tag;
+			const gchar *description;
+			const gchar *files;
+			gint n_files = 0;
+
+			id = tracker_sparql_cursor_get_string (cursor, 0, NULL);
+			files = tracker_sparql_cursor_get_string (cursor, 3, NULL);
+			n_files = atoi (files);
+
+			tag = tracker_sparql_cursor_get_string (cursor, 1, NULL);
+			description = tracker_sparql_cursor_get_string (cursor, 2, NULL);
+
+			if (description && *description == '\0') {
+				description = NULL;
+			}
+
+			g_print ("  %s %s%s%s\n",
+			         tag,
+			         description ? "(" : "",
+			         description ? description : "",
+			         description ? ")" : "");
+
+			if (show_files && n_files > 0) {
+				get_all_tags_show_tag_id (connection, id);
+			} else {
+				g_print ("    %s\n", id);
+				g_print ("    ");
+				g_print (g_dngettext (NULL,
+				                      "%d file",
+				                      "%d files",
+				                      n_files),
+				         n_files);
+				g_print ("\n");
+			}
 
 			count++;
 		}
 
-                if (count == 0) {
-                        g_print ("  %s\n", _("None"));
-                }
+		if (count == 0) {
+			g_print ("  %s\n", _("None"));
+		}
 
 		g_print ("\n");
 
@@ -512,7 +512,7 @@ print_file_report (TrackerSparqlCursor *cursor,
                    const gchar         *found_msg,
                    const gchar         *not_found_msg)
 {
-        gint i;
+	gint i;
 
 	if (!cursor || !uris) {
 		g_print ("  %s\n", _("No files were modified"));
@@ -522,17 +522,17 @@ print_file_report (TrackerSparqlCursor *cursor,
 	for (i = 0; uris[i]; i++) {
 		gboolean found = FALSE;
 
-                g_print ("*** checking uri:'%s' and rewinding cursor\n", uris[i]);
+		g_print ("*** checking uri:'%s' and rewinding cursor\n", uris[i]);
 
-                while (tracker_sparql_cursor_next (cursor, NULL, NULL)) {
+		while (tracker_sparql_cursor_next (cursor, NULL, NULL)) {
 			const gchar *str;
 
 			str = tracker_sparql_cursor_get_string (cursor, 1, NULL);
-                        g_print ("***   comparing to str:'%s'\n", str);
+			g_print ("***   comparing to str:'%s'\n", str);
 
 			if (g_strcmp0 (str, uris[i]) == 0) {
 				found = TRUE;
-                                g_print ("***   FOUND FOUND FOUND!\n");
+				g_print ("***   FOUND FOUND FOUND!\n");
 				break;
 			}
 		}
@@ -541,7 +541,7 @@ print_file_report (TrackerSparqlCursor *cursor,
 		         found ? found_msg : not_found_msg,
 		         uris[i]);
 
-                tracker_sparql_cursor_rewind (cursor);
+		tracker_sparql_cursor_rewind (cursor);
 	}
 }
 
@@ -549,7 +549,7 @@ static gboolean
 add_tag_for_urns (TrackerSparqlConnection *connection,
                   GStrv                    files,
                   const gchar             *tag,
-		  const gchar             *description)
+                  const gchar             *description)
 {
 	TrackerSparqlCursor *cursor;
 	GError *error = NULL;
@@ -626,47 +626,46 @@ add_tag_for_urns (TrackerSparqlConnection *connection,
 	/* First we check if the tag is already set and only add if it
 	 * is, then we add the urns specified to the new tag.
 	 */
-        if (cursor) {
-                GStrv urns_strv;
-                gchar *filter;
-
-                urns_strv = result_to_strv (cursor, 0);
-                filter = get_filter_string (urns_strv, TRUE, NULL);
-
-                /* Add tag to specific urns */
-                query = g_strdup_printf ("INSERT { "
-                                         "  ?urn nao:hasTag ?id "
-                                         "} "
-                                         "WHERE {"
-                                         "  ?urn nie:url ?f ."
-                                         "  ?id nao:prefLabel %s "
-                                         "  %s "
-                                         "}",
-                                         tag_escaped,
-                                         filter);
-
-                tracker_sparql_connection_update (connection, query, NULL, &error);
-                g_strfreev (urns_strv);
-                g_free (filter);
-                g_free (query);
-
-                if (error) {
-                        g_printerr ("%s, %s\n",
-                                    _("Could not add tag to files"),
-                                    error->message);
-                        g_error_free (error);
-                        g_free (tag_escaped);
-                        g_object_unref (cursor);
-
-                        return FALSE;
-                }
-
-                print_file_report (cursor, uris,
-                                   _("Tagged"),
-                                   _("Not tagged, file is not indexed"));
-
-                g_object_unref (cursor);
-        }
+	if (cursor) {
+		GStrv urns_strv;
+		gchar *filter;
+
+		urns_strv = result_to_strv (cursor, 0);
+		filter = get_filter_string (urns_strv, TRUE, NULL);
+
+		/* Add tag to specific urns */
+		query = g_strdup_printf ("INSERT { "
+		                         "  ?urn nao:hasTag ?id "
+		                         "} "
+		                         "WHERE {"
+		                         "  ?urn nie:url ?f ."
+		                         "  ?id nao:prefLabel %s "
+		                         "  %s "
+		                         "}",
+		                         tag_escaped,
+		                         filter);
+
+		tracker_sparql_connection_update (connection, query, NULL, &error);
+		g_strfreev (urns_strv);
+		g_free (filter);
+		g_free (query);
+
+		if (error) {
+			g_printerr ("%s, %s\n",
+			            _("Could not add tag to files"),
+			            error->message);
+			g_error_free (error);
+			g_free (tag_escaped);
+			g_object_unref (cursor);
+
+			return FALSE;
+		}
+
+		print_file_report (cursor, uris, _("Tagged"),
+		                   _("Not tagged, file is not indexed"));
+
+		g_object_unref (cursor);
+	}
 
 	g_strfreev (uris);
 	g_free (tag_escaped);
@@ -723,15 +722,15 @@ remove_tag_for_urns (TrackerSparqlConnection *connection,
 			g_free (tag_escaped);
 			g_strfreev (uris);
 
-                        if (tag_cursor) {
-                                g_object_unref (tag_cursor);
-                        }
+			if (tag_cursor) {
+				g_object_unref (tag_cursor);
+			}
 
 			return TRUE;
 		}
 
-                urn = tracker_sparql_cursor_get_string (tag_cursor, 0, NULL);
-                urns_cursor = get_file_urns (connection, uris, urn);
+		urn = tracker_sparql_cursor_get_string (tag_cursor, 0, NULL);
+		urns_cursor = get_file_urns (connection, uris, urn);
 
 		if (!urns_cursor || !tracker_sparql_cursor_next (urns_cursor, NULL, NULL)) {
 			g_print ("%s\n",
@@ -739,11 +738,11 @@ remove_tag_for_urns (TrackerSparqlConnection *connection,
 
 			g_strfreev (uris);
 			g_free (tag_escaped);
-                        g_object_unref (tag_cursor);
+			g_object_unref (tag_cursor);
 
-                        if (urns_cursor) {
-                                g_object_unref (urns_cursor);
-                        }
+			if (urns_cursor) {
+				g_object_unref (urns_cursor);
+			}
 
 			return TRUE;
 		}
@@ -762,7 +761,7 @@ remove_tag_for_urns (TrackerSparqlConnection *connection,
 		                         filter);
 		g_free (filter);
 
-                g_object_unref (tag_cursor);
+		g_object_unref (tag_cursor);
 	} else {
 		/* Remove tag completely */
 		query = g_strdup_printf ("DELETE { "
@@ -788,17 +787,16 @@ remove_tag_for_urns (TrackerSparqlConnection *connection,
 		return FALSE;
 	}
 
-	g_print ("%s\n",
-	         _("Tag was removed successfully"));
+	g_print ("%s\n", _("Tag was removed successfully"));
 
-        if (urns_cursor) {
-                print_file_report (urns_cursor, uris,
-                                   _("Untagged"),
-                                   _("File not indexed or already untagged"));
-                g_object_unref (urns_cursor);
-        }
+	if (urns_cursor) {
+		print_file_report (urns_cursor, uris,
+		                   _("Untagged"),
+		                   _("File not indexed or already untagged"));
+		g_object_unref (urns_cursor);
+	}
 
-        g_strfreev (uris);
+	g_strfreev (uris);
 
 	return TRUE;
 }
@@ -807,7 +805,7 @@ static gboolean
 get_tags_by_file (TrackerSparqlConnection *connection,
                   const gchar             *uri)
 {
-        TrackerSparqlCursor *cursor;
+	TrackerSparqlCursor *cursor;
 	GError *error = NULL;
 	gchar *query;
 
@@ -837,16 +835,16 @@ get_tags_by_file (TrackerSparqlConnection *connection,
 		g_print ("  %s\n",
 		         _("No tags were found"));
 	} else {
-                gint count = 0;
+		gint count = 0;
 
 		while (tracker_sparql_cursor_next (cursor, NULL, NULL)) {
-                        g_print ("  %s\n", tracker_sparql_cursor_get_string (cursor, 1, NULL));
-                        count++;
+			g_print ("  %s\n", tracker_sparql_cursor_get_string (cursor, 1, NULL));
+			count++;
 		}
 
-                if (count == 0) {
-                        g_print ("  %s\n", _("None"));
-                }
+		if (count == 0) {
+			g_print ("  %s\n", _("None"));
+		}
 
 		g_print ("\n");
 
@@ -861,7 +859,7 @@ main (int argc, char **argv)
 {
 	TrackerSparqlConnection *connection;
 	GOptionContext *context;
-        GError *error = NULL;
+	GError *error = NULL;
 	const gchar *failed = NULL;
 
 	setlocale (LC_ALL, "");



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