Index: tracker-db.c =================================================================== RCS file: /cvs/gnome/tracker/src/trackerd/tracker-db.c,v retrieving revision 1.26 diff -u -d -r1.26 tracker-db.c --- tracker-db.c 16 Sep 2006 16:54:01 -0000 1.26 +++ tracker-db.c 20 Sep 2006 05:52:04 -0000 @@ -187,7 +187,7 @@ time = tracker_str_to_date (dvalue); - //tracker_log ("processing date %s with format %s and time %ld", avalue, dvalue, time); + //g_message ("processing date %s with format %s and time %ld", avalue, dvalue, time); g_free (dvalue); @@ -195,7 +195,7 @@ return; } else { evalue = tracker_long_to_str (time); - // tracker_log ("date is %s", evalue); + // g_message ("date is %s", evalue); } @@ -418,7 +418,7 @@ } } - //tracker_log ("inserting pending file for %s with action %s", uri, tracker_actions[action]); + //g_message ("inserting pending file for %s with action %s", uri, tracker_actions[action]); /* signal respective thread that data is available and awake it if its asleep */ if (action == TRACKER_ACTION_EXTRACT_METADATA) { Index: tracker-db-mysql.c =================================================================== RCS file: /cvs/gnome/tracker/src/trackerd/tracker-db-mysql.c,v retrieving revision 1.11 diff -u -d -r1.11 tracker-db-mysql.c --- tracker-db-mysql.c 16 Sep 2006 16:54:01 -0000 1.11 +++ tracker-db-mysql.c 20 Sep 2006 05:52:04 -0000 @@ -140,7 +140,7 @@ } if (str) { - tracker_log (str); + g_message (str); g_free (str); } } @@ -256,7 +256,7 @@ g_free (str); - tracker_log ("DB initialised - embedded mysql version is %d", mysql_get_client_version ()); + g_message ("DB initialised - embedded mysql version is %d", mysql_get_client_version ()); return TRUE; } @@ -300,14 +300,14 @@ db_con->db = mysql_init (NULL); if (!db_con->db) { - tracker_log ("Fatal error - mysql_init failed"); + g_message ("Fatal error - mysql_init failed"); exit (1); } mysql_options (db_con->db, MYSQL_OPT_USE_EMBEDDED_CONNECTION, NULL); if (!mysql_real_connect (db_con->db, NULL, "root", NULL, dbname, 0, NULL, CLIENT_MULTI_STATEMENTS)) { - tracker_log ("Fatal error : mysql_real_connect failed: %s", mysql_error (db_con->db)); + g_message ("Fatal error : mysql_real_connect failed: %s", mysql_error (db_con->db)); exit (1); } @@ -328,12 +328,12 @@ *stmt = mysql_stmt_init (db); if (!*stmt) { - tracker_log (" mysql_stmt_init(), out of memory"); + g_message (" mysql_stmt_init(), out of memory"); exit (1); } if (mysql_stmt_prepare (*stmt, query, strlen (query)) != 0) { - tracker_log (" mysql_stmt_prepare(), query failed due to %s", mysql_stmt_error (*stmt)); + g_message (" mysql_stmt_prepare(), query failed due to %s", mysql_stmt_error (*stmt)); return -5; } @@ -413,7 +413,7 @@ } } - tracker_log ("lock failure"); + g_message ("lock failure"); g_free (lock_file); g_free (tmp_file); @@ -452,7 +452,7 @@ int i, result; if (param_count > 16) { - tracker_log ("Too many parameters to execute query"); + g_message ("Too many parameters to execute query"); return -1; } @@ -468,7 +468,7 @@ str = va_arg (args, char *); if (strlen(str) > 2048) { - tracker_log ("Warning - length of parameter %s is too long", str); + g_message ("Warning - length of parameter %s is too long", str); } strncpy (params[i], str, 2048); @@ -483,7 +483,7 @@ } if (mysql_stmt_bind_param (stmt, bind)) { - tracker_log ("bind failed"); + g_message ("bind failed"); return -1; } @@ -493,7 +493,7 @@ } if (mysql_stmt_execute (stmt)) { unlock_db (); - tracker_log ("error %s occured whilst executing stmt", mysql_stmt_error (stmt)); + g_message ("error %s occured whilst executing stmt", mysql_stmt_error (stmt)); return -1; } unlock_db (); @@ -503,7 +503,7 @@ result = mysql_stmt_affected_rows (stmt); if (mysql_stmt_free_result (stmt)) { - tracker_log ("ERROR Freeing statement %s", mysql_stmt_error (stmt)); + g_message ("ERROR Freeing statement %s", mysql_stmt_error (stmt)); } //mysql_stmt_reset (stmt); @@ -525,7 +525,7 @@ char **result; if (param_count > 16) { - tracker_log ("Too many parameters to execute query"); + g_message ("Too many parameters to execute query"); return NULL; } @@ -539,7 +539,7 @@ str = va_arg (args, char *); if (strlen (str) > 254) { - tracker_log ("Warning - length of parameter %s is too long", str); + g_message ("Warning - length of parameter %s is too long", str); } strncpy (params[i], str, 255); @@ -555,7 +555,7 @@ } if (mysql_stmt_bind_param (stmt, bind)) { - tracker_log ("bind failed"); + g_message ("bind failed"); } prepare_meta_result = mysql_stmt_result_metadata (stmt); @@ -567,7 +567,7 @@ return NULL; } if (mysql_stmt_execute (stmt)) { - tracker_log ("error executing stmt"); + g_message ("error executing stmt"); } unlock_db (); @@ -585,15 +585,15 @@ /* Bind the result buffers */ if (mysql_stmt_bind_result (stmt, bind)) { - tracker_log (" mysql_stmt_bind_result() failed"); - tracker_log (" %s", mysql_stmt_error (stmt)); + g_message (" mysql_stmt_bind_result() failed"); + g_message (" %s", mysql_stmt_error (stmt)); return NULL; } /* Now buffer all results to client */ if (mysql_stmt_store_result (stmt)) { - tracker_log (" mysql_stmt_store_result() failed"); - tracker_log (" %s", mysql_stmt_error (stmt)); + g_message (" mysql_stmt_store_result() failed"); + g_message (" %s", mysql_stmt_error (stmt)); return NULL; } @@ -634,7 +634,7 @@ mysql_free_result (prepare_meta_result); if (mysql_stmt_free_result (stmt)) { - tracker_log ("ERROR Freeing statement"); + g_message ("ERROR Freeing statement"); } //mysql_stmt_reset (stmt); @@ -663,7 +663,7 @@ g_return_val_if_fail (query, NULL); - //tracker_log ("executing query:\n%s\n", query); + //g_message ("executing query:\n%s\n", query); g_get_current_time (&before); if (!lock_db ()) { return NULL; @@ -673,7 +673,7 @@ if (mysql_query (db, query) != 0) { unlock_db (); - tracker_log ("tracker_exec_sql failed: %s [%s]", mysql_error (db), query); + g_message ("tracker_exec_sql failed: %s [%s]", mysql_error (db), query); return res; } unlock_db (); @@ -682,11 +682,11 @@ elapsed = (1000 * (after.tv_sec - before.tv_sec)) + ((after.tv_usec - before.tv_usec) / 1000); -// tracker_log ("Query execution time is %f ms\n\n", elapsed); +// g_message ("Query execution time is %f ms\n\n", elapsed); if (mysql_field_count (db) > 0) { if (!(res = mysql_store_result (db))) { - tracker_log ("tracker_exec_sql failed: %s [%s]", mysql_error (db), query); + g_message ("tracker_exec_sql failed: %s [%s]", mysql_error (db), query); } } @@ -886,7 +886,7 @@ str = va_arg (args, char *); if (!str) { - tracker_log ("Warning - parameter %d is null", i); + g_message ("Warning - parameter %d is null", i); param = NULL; } else { param = tracker_escape_string (db_con, str); @@ -931,7 +931,7 @@ char *sql_file; char *query; - tracker_log ("Creating system database..."); + g_message ("Creating system database..."); db_con = db_connect (NULL); tracker_exec_sql (db_con, "CREATE DATABASE mysql"); @@ -942,7 +942,7 @@ sql_file = g_strdup (DATADIR "/tracker/mysql-system.sql"); if (!g_file_get_contents (sql_file, &query, NULL, NULL)) { - tracker_log ("Tracker cannot read required file %s - Please reinstall tracker or check read permissions on the file if it exists", sql_file); + g_message ("Tracker cannot read required file %s - Please reinstall tracker or check read permissions on the file if it exists", sql_file); g_assert (FALSE); } else { char **queries, **queries_p; @@ -971,12 +971,12 @@ char *sql_file; char *query; - tracker_log ("Creating stored procedures..."); + g_message ("Creating stored procedures..."); sql_file = g_strdup (DATADIR "/tracker/mysql-stored-procs.sql"); if (!g_file_get_contents (sql_file, &query, NULL, NULL)) { - tracker_log ("Tracker cannot read required file %s - Please reinstall tracker or check read permissions on the file if it exists", sql_file); + g_message ("Tracker cannot read required file %s - Please reinstall tracker or check read permissions on the file if it exists", sql_file); g_assert (FALSE); } else { char **queries, **queries_p; @@ -1008,7 +1008,7 @@ char *sql_file; char *query; - tracker_log ("Creating tracker database..."); + g_message ("Creating tracker database..."); db_con = db_connect (NULL); tracker_mysql_exec_sql (db_con->db, "CREATE DATABASE tracker"); @@ -1017,10 +1017,10 @@ db_con = db_connect ("tracker"); sql_file = g_strdup (DATADIR "/tracker/mysql-tracker.sql"); - tracker_log ("Creating tables..."); + g_message ("Creating tables..."); if (!g_file_get_contents (sql_file, &query, NULL, NULL)) { - tracker_log ("Tracker cannot read required file %s - Please reinstall tracker or check read permissions on the file if it exists", sql_file); + g_message ("Tracker cannot read required file %s - Please reinstall tracker or check read permissions on the file if it exists", sql_file); g_assert (FALSE); } else { char **queries, **queries_p; @@ -1051,7 +1051,7 @@ void -tracker_log_sql (DBConnection *db_con, const char *query) +g_message_sql (DBConnection *db_con, const char *query) { MYSQL_RES *res; MYSQL_ROW row; @@ -1087,7 +1087,7 @@ } str = g_string_free (contents, FALSE); - tracker_log ("results of query %s is \n%s\n\n", query, str); + g_message ("results of query %s is \n%s\n\n", query, str); g_free (str); mysql_free_result (res); @@ -1110,7 +1110,7 @@ res = tracker_mysql_exec_sql (db_con->db, "show tables"); - tracker_log ("Checking for Options table..."); + g_message ("Checking for Options table..."); found_options = FALSE; @@ -1118,7 +1118,7 @@ while ((row = mysql_fetch_row (res))) { if ((row[0] && (strcmp (row[0], "Options") == 0))) { - tracker_log ("Options table is present"); + g_message ("Options table is present"); found_options = TRUE; break; } @@ -1127,7 +1127,7 @@ mysql_free_result (res); if (!found_options) { - tracker_log ("Cannot find Options table - your database is out of date and will need to be rebuilt"); + g_message ("Cannot find Options table - your database is out of date and will need to be rebuilt"); tracker_mysql_exec_sql (db_con->db, "Drop Database tracker"); tracker_create_db (); return TRUE; @@ -1151,10 +1151,10 @@ i = atoi (version); mysql_free_result (res); - tracker_log ("Checking tracker DB version...Current version is %d and needed version is %d", i, TRACKER_DB_VERSION_REQUIRED); + g_message ("Checking tracker DB version...Current version is %d and needed version is %d", i, TRACKER_DB_VERSION_REQUIRED); if (i < 4) { - tracker_log ("Your database is out of date and will need to be rebuilt and all your files reindexed.\nThis may take a while...please wait..."); + g_message ("Your database is out of date and will need to be rebuilt and all your files reindexed.\nThis may take a while...please wait..."); tracker_exec_sql (db_con, "Drop Database tracker"); create_tracker_db (); return TRUE; @@ -1167,7 +1167,7 @@ sql_file = g_strconcat (DATADIR, "/tracker/tracker-db-table-update", version, ".sql", NULL); - tracker_log ("Please wait while database is being updated to the latest version"); + g_message ("Please wait while database is being updated to the latest version"); if (g_file_get_contents (sql_file, &query, NULL, NULL)) { @@ -1188,12 +1188,12 @@ */ /* regenerate SPs */ - tracker_log ("Creating stored procedures..."); + g_message ("Creating stored procedures..."); sql_file = g_strdup (DATADIR "/tracker/mysql-stored-procs.sql"); if (!g_file_get_contents (sql_file, &query, NULL, NULL)) { - tracker_log ("Tracker cannot read required file %s - Please reinstall tracker or check read permissions on the file if it exists", sql_file); + g_message ("Tracker cannot read required file %s - Please reinstall tracker or check read permissions on the file if it exists", sql_file); g_assert (FALSE); } else { char **queries, **queries_p; @@ -1235,17 +1235,17 @@ file_name_in_locale = g_filename_from_utf8 (file_name, -1, NULL, NULL, NULL); if (!file_name_in_locale) { - tracker_log ("******ERROR**** file_name could not be converted to locale format"); + g_message ("******ERROR**** file_name could not be converted to locale format"); return; } file = g_fopen (file_name_in_locale, "r"); - //tracker_log ("saving text to db with file_id %ld", file_id); + //g_message ("saving text to db with file_id %ld", file_id); g_free (file_name_in_locale); if (!file) { - tracker_log ("Could not open file %s", file_name); + g_message ("Could not open file %s", file_name); return; } @@ -1265,7 +1265,7 @@ g_free (res); } else { - tracker_log ("Could not get metadata for File.Content"); + g_message ("Could not get metadata for File.Content"); return; } @@ -1292,7 +1292,7 @@ /* Bind the buffers */ if (mysql_stmt_bind_param (db_con->insert_contents_stmt, bind)) { - tracker_log ("binding error : %s\n", mysql_stmt_error (db_con->insert_contents_stmt)); + g_message ("binding error : %s\n", mysql_stmt_error (db_con->insert_contents_stmt)); g_free (str_meta_id); g_free (str_file_id); fclose (file); @@ -1337,7 +1337,7 @@ if (mysql_stmt_send_long_data (db_con->insert_contents_stmt, 2, buffer, strlen (buffer)) != 0) { - tracker_log ("error sending data : %s\n", mysql_stmt_error (db_con->insert_contents_stmt)); + g_message ("error sending data : %s\n", mysql_stmt_error (db_con->insert_contents_stmt)); g_free (str_meta_id); g_free (str_file_id); fclose (file); @@ -1355,10 +1355,10 @@ if (bytes_read > 3) { if (mysql_stmt_execute (db_con->insert_contents_stmt) != 0) { - tracker_log ("insert metadata indexed query failed :%s", mysql_stmt_error (db_con->insert_contents_stmt)); + g_message ("insert metadata indexed query failed :%s", mysql_stmt_error (db_con->insert_contents_stmt)); } else { - //tracker_log ("%d bytes of text successfully inserted into file id %s", bytes_read, str_file_id); + //g_message ("%d bytes of text successfully inserted into file id %s", bytes_read, str_file_id); } } unlock_db (); @@ -1368,7 +1368,7 @@ fclose (file); if (mysql_stmt_free_result (db_con->insert_contents_stmt)) { - tracker_log ("ERROR Freeing file contents statement"); + g_message ("ERROR Freeing file contents statement"); } } @@ -1518,7 +1518,7 @@ res = tracker_exec_proc (db_con, "SetMetadata", 5, service, id, key, value, str_write); if (res && res[0][0]) { - tracker_log ("Warning: Metadata could not be set for %s with value %s due to %s", key, value, res[0][0]); + g_message ("Warning: Metadata could not be set for %s with value %s due to %s", key, value, res[0][0]); tracker_db_free_result (res); } } Index: tracker-db-mysql.h =================================================================== RCS file: /cvs/gnome/tracker/src/trackerd/tracker-db-mysql.h,v retrieving revision 1.9 diff -u -d -r1.9 tracker-db-mysql.h --- tracker-db-mysql.h 16 Sep 2006 16:54:01 -0000 1.9 +++ tracker-db-mysql.h 20 Sep 2006 05:52:04 -0000 @@ -74,7 +74,7 @@ char *** tracker_exec_proc (DBConnection *db_con, const char *procedure, int param_count, ...); char *** tracker_exec_sql (DBConnection *db_con, const char *query); char *** tracker_exec_sql_ignore_nulls (DBConnection *db_con, const char *query); -void tracker_log_sql (DBConnection *db_con, const char *query); +void g_message_sql (DBConnection *db_con, const char *query); void tracker_create_db (void); void tracker_db_load_stored_procs (DBConnection *db_con); void tracker_db_save_file_contents (DBConnection *db_con, const char *file_name, FileInfo *info); Index: tracker-db-sqlite.c =================================================================== RCS file: /cvs/gnome/tracker/src/trackerd/tracker-db-sqlite.c,v retrieving revision 1.10 diff -u -d -r1.10 tracker-db-sqlite.c --- tracker-db-sqlite.c 14 Sep 2006 11:48:09 -0000 1.10 +++ tracker-db-sqlite.c 20 Sep 2006 05:52:05 -0000 @@ -121,7 +121,7 @@ str = g_strconcat (value, NULL); } } - tracker_log (str); + g_message (str); g_free (str); str = NULL; @@ -206,19 +206,19 @@ FILE *file; char buffer[8192]; - tracker_log ("Using Sqlite version %s", sqlite3_version); + g_message ("Using Sqlite version %s", sqlite3_version); sequence_mutex = g_mutex_new (); /* load prepared queries */ prepared_queries = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); - tracker_log ("Loading prepared queries..."); + g_message ("Loading prepared queries..."); char *sql_file = g_strdup (DATADIR "/tracker/sqlite-stored-procs.sql"); if (!g_file_test (sql_file, G_FILE_TEST_EXISTS)) { - tracker_log ("Tracker cannot read required file %s - Please reinstall tracker or check read permissions on the file if it exists", sql_file); + g_message ("Tracker cannot read required file %s - Please reinstall tracker or check read permissions on the file if it exists", sql_file); g_assert (FALSE); } @@ -243,7 +243,7 @@ char *query = g_strdup (sep + 1); char *name = g_strdup (buffer); - //tracker_log ("installing query %s with sql %s", name, query); + //g_message ("installing query %s with sql %s", name, query); g_hash_table_insert (prepared_queries, name, query); } else { @@ -291,7 +291,7 @@ if (key && stmt) { if (sqlite3_finalize (stmt)!= SQLITE_OK) { - tracker_log ("Error statement could not be finalized for %s with error %s", (char *)key, sqlite3_errmsg (db_con->db)); + g_message ("Error statement could not be finalized for %s with error %s", (char *)key, sqlite3_errmsg (db_con->db)); } } @@ -305,7 +305,7 @@ db_con->thread = "main"; } - tracker_log ("starting database closure for thread %s", db_con->thread); + g_message ("starting database closure for thread %s", db_con->thread); // sqlite3_interrupt (db_con->db); @@ -319,9 +319,9 @@ g_hash_table_destroy (db_con->statements); if (sqlite3_close (db_con->db) != SQLITE_OK) { - tracker_log ("ERROR : Database close operation failed for thread %s due to %s", db_con->thread, sqlite3_errmsg (db_con->db)); + g_message ("ERROR : Database close operation failed for thread %s due to %s", db_con->thread, sqlite3_errmsg (db_con->db)); } else { - tracker_log ("Database closed for thread %s", db_con->thread); + g_message ("Database closed for thread %s", db_con->thread); } } @@ -338,7 +338,7 @@ if (sqlite3_open (dbname, &db_con->db) != SQLITE_OK) { - tracker_log ("Fatal Error : Can't open database at %s: %s", dbname, sqlite3_errmsg (db_con->db)); + g_message ("Fatal Error : Can't open database at %s: %s", dbname, sqlite3_errmsg (db_con->db)); exit (1); } @@ -432,7 +432,7 @@ } } - tracker_log ("lock failure"); + g_message ("lock failure"); g_free (lock_file); g_free (tmp_file); return FALSE; @@ -498,7 +498,7 @@ busy_count++; if (busy_count > 1000) { - tracker_log ("excessive busy count in query %s and thread %s", query, db_con->thread); + g_message ("excessive busy count in query %s and thread %s", query, db_con->thread); exit(1); } @@ -513,7 +513,7 @@ if (i != SQLITE_OK) { unlock_db (); - tracker_log ("query %s failed with error : %s", query, msg); + g_message ("query %s failed with error : %s", query, msg); g_free (msg); return NULL; } @@ -530,8 +530,8 @@ int totalrows = (rows+1) * cols; - //tracker_log ("totalrows is %d", totalrows); - //for (i=0;idb, query, -1, &stmt, 0); if (rc == SQLITE_OK && stmt != NULL) { - tracker_log ("successfully prepared query %s", procedure); + g_message ("successfully prepared query %s", procedure); g_hash_table_insert (db_con->statements, g_strdup (procedure), stmt); } else { - tracker_log ("ERROR : failed to prepare query %s with sql %s due to %s", procedure, query, sqlite3_errmsg (db_con->db)); + g_message ("ERROR : failed to prepare query %s with sql %s due to %s", procedure, query, sqlite3_errmsg (db_con->db)); return NULL; } } @@ -647,7 +647,7 @@ va_start (args, param_count); if (param_count != sqlite3_bind_parameter_count (stmt)) { - tracker_log ("ERROR : incorrect no of paramters %d supplied to %s", param_count, procedure); + g_message ("ERROR : incorrect no of paramters %d supplied to %s", param_count, procedure); } @@ -656,11 +656,11 @@ str = va_arg (args, char *); if (!str) { - tracker_log ("Warning - parameter %d is null", i); + g_message ("Warning - parameter %d is null", i); } if (sqlite3_bind_text (stmt, i+1, str, strlen (str), SQLITE_TRANSIENT) != SQLITE_OK) { - tracker_log ("ERROR : paramter %d could not be bound to %s", i, procedure); + g_message ("ERROR : paramter %d could not be bound to %s", i, procedure); } } @@ -689,7 +689,7 @@ busy_count++; if (busy_count > 1000) { - tracker_log ("excessive busy count in query %s and thread %s", procedure, db_con->thread); + g_message ("excessive busy count in query %s and thread %s", procedure, db_con->thread); exit(0); } @@ -714,7 +714,7 @@ const char *st = (char *)sqlite3_column_text (stmt, i); if (st) { new_row[i] = g_strdup (st); - //tracker_log ("%s : row %d, col %d is %s", procedure, row, i, st); + //g_message ("%s : row %d, col %d is %s", procedure, row, i, st); } } @@ -732,7 +732,7 @@ } if (rc != SQLITE_DONE) { - tracker_log ("ERROR : prepared query %s failed due to %s", procedure, sqlite3_errmsg (db_con->db)); + g_message ("ERROR : prepared query %s failed due to %s", procedure, sqlite3_errmsg (db_con->db)); } if (!result || row == 0) { @@ -814,25 +814,25 @@ - tracker_log ("Creating tracker database..."); + g_message ("Creating tracker database..."); db_con = tracker_db_connect (); sql_file = g_strdup (DATADIR "/tracker/sqlite-tracker.sql"); - tracker_log ("Creating tables..."); + g_message ("Creating tables..."); if (!g_file_get_contents (sql_file, &query, NULL, NULL)) { - tracker_log ("Tracker cannot read required file %s - Please reinstall tracker or check read permissions on the file if it exists", sql_file); + g_message ("Tracker cannot read required file %s - Please reinstall tracker or check read permissions on the file if it exists", sql_file); g_assert (FALSE); } else { queries = g_strsplit_set (query, ";", -1); for (queries_p = queries; *queries_p; queries_p++) { if (*queries_p) { - //tracker_log ("creating table %s", *queries_p); + //g_message ("creating table %s", *queries_p); tracker_exec_sql (db_con, *queries_p); - //tracker_log ("Table created"); + //g_message ("Table created"); } } - tracker_log ("finished creating tables"); + g_message ("finished creating tables"); g_strfreev (queries); g_free (query); @@ -848,7 +848,7 @@ void -tracker_log_sql (DBConnection *db_con, const char *query) +g_message_sql (DBConnection *db_con, const char *query) { char ***res = NULL; @@ -920,10 +920,10 @@ tracker_db_free_result (res); - tracker_log ("Checking tracker DB version...Current version is %d and needed version is %d", i, TRACKER_DB_VERSION_REQUIRED); + g_message ("Checking tracker DB version...Current version is %d and needed version is %d", i, TRACKER_DB_VERSION_REQUIRED); if (i < 4) { - tracker_log ("Your database is out of date and will need to be rebuilt and all your files reindexed.\nThis may take a while...please wait..."); + g_message ("Your database is out of date and will need to be rebuilt and all your files reindexed.\nThis may take a while...please wait..."); tracker_db_close (db_con); @@ -944,7 +944,7 @@ sql_file = g_strconcat (DATADIR, "/tracker/tracker-db-table-update", version, ".sql", NULL); - tracker_log ("Please wait while database is being updated to the latest version"); + g_message ("Please wait while database is being updated to the latest version"); if (g_file_get_contents (sql_file, &query, NULL, NULL)) { @@ -993,7 +993,7 @@ argv[2] = g_strdup (temp_file_name); argv[3] = NULL; - tracker_log ("extracting parsed text for %s", file_as_text); + g_message ("extracting parsed text for %s", file_as_text); if (g_spawn_sync (NULL, argv, @@ -1060,7 +1060,7 @@ } } else { - tracker_log ("Error : could not find file %s", file_as_text); + g_message ("Error : could not find file %s", file_as_text); } @@ -1082,22 +1082,22 @@ sqlite3_stmt *stmt; int rc; - //tracker_log ("parsing file"); + //g_message ("parsing file"); //tracker_metadata_parse_text_contents (file_as_text, file_id); - //tracker_log ("parsing finished"); + //g_message ("parsing finished"); file = fopen (file_name,"r"); - //tracker_log ("saving text to db with file_id %ld", file_id); + //g_message ("saving text to db with file_id %ld", file_id); if (!file) { - tracker_log ("Could not open file %s", file_name); + g_message ("Could not open file %s", file_name); return; } def = tracker_db_get_field_def (db_con, "File.Content"); if (!def || !def->id) { - tracker_log ("Could not get metadata for File.Content"); + g_message ("Could not get metadata for File.Content"); return; } @@ -1186,7 +1186,7 @@ busy_count++; if (busy_count > 1000) { - tracker_log ("excessive busy count in query %s and thread %s", "save file contents", db_con->thread); + g_message ("excessive busy count in query %s and thread %s", "save file contents", db_con->thread); exit(0); } @@ -1204,7 +1204,7 @@ } if (rc == SQLITE_DONE) { - tracker_log ("%d bytes of text successfully inserted into file id %s", bytes_read, str_file_id); + g_message ("%d bytes of text successfully inserted into file id %s", bytes_read, str_file_id); } @@ -1335,7 +1335,7 @@ case 1: res = tracker_exec_proc (db_con, "GetMetadataString", 2, id, def->id); break; case 2: res = tracker_exec_proc (db_con, "GetMetadataNumeric", 2, id, def->id); break; case 3: res = tracker_exec_proc (db_con, "GetMetadataNumeric", 2, id, def->id); break; - default: tracker_log ("Error: metadata could not be retrieved as type %d is not supported", def->type); res = NULL; + default: g_message ("Error: metadata could not be retrieved as type %d is not supported", def->type); res = NULL; } tracker_db_free_field_def (def); @@ -1368,7 +1368,7 @@ case 1: tracker_exec_proc (db_con, "SetMetadataString", 3, id, def->id, value); break; case 2: tracker_exec_proc (db_con, "SetMetadataNumeric", 3, id, def->id, value); break; case 3: tracker_exec_proc (db_con, "SetMetadataNumeric", 3, id, def->id, value); break; - default: tracker_log ("Error: metadata could not be set as type %d is not supported", def->type); + default: g_message ("Error: metadata could not be set as type %d is not supported", def->type); } tracker_db_free_field_def (def); @@ -1413,7 +1413,7 @@ if (!res || !res[0][0]) { g_mutex_unlock (sequence_mutex); - tracker_log ("ERROR : could not create service - GetNewID failed"); + g_message ("ERROR : could not create service - GetNewID failed"); return; } @@ -1548,7 +1548,7 @@ if (row && row[0]) { int pending_file_count = atoi (row[0]); - tracker_log ("%d files are pending", pending_file_count); + g_message ("%d files are pending", pending_file_count); has_pending = (pending_file_count > 0); } @@ -1678,7 +1678,7 @@ } - //tracker_log ("inserting time of %s", time_str); + //g_message ("inserting time of %s", time_str); if (is_dir) { tracker_exec_proc (db_con, "InsertPendingFile", 6, id, action, time_str, uri, mime, "1"); Index: tracker-db-sqlite.h =================================================================== RCS file: /cvs/gnome/tracker/src/trackerd/tracker-db-sqlite.h,v retrieving revision 1.7 diff -u -d -r1.7 tracker-db-sqlite.h --- tracker-db-sqlite.h 13 Sep 2006 17:11:54 -0000 1.7 +++ tracker-db-sqlite.h 20 Sep 2006 05:52:05 -0000 @@ -77,7 +77,7 @@ void tracker_db_prepare_queries (DBConnection *db_con); char *** tracker_exec_proc (DBConnection *db_con, const char *procedure, int param_count, ...); char *** tracker_exec_sql (DBConnection *db_con, const char *query); -void tracker_log_sql (DBConnection *db_con, const char *query); +void g_message_sql (DBConnection *db_con, const char *query); void tracker_create_db (); void tracker_db_load_stored_procs (DBConnection *db_con); void tracker_db_save_file_contents (DBConnection *db_con, const char *file_name, FileInfo *info); Index: tracker-dbus.c =================================================================== RCS file: /cvs/gnome/tracker/src/trackerd/tracker-dbus.c,v retrieving revision 1.11 diff -u -d -r1.11 tracker-dbus.c --- tracker-dbus.c 7 Sep 2006 11:06:15 -0000 1.11 +++ tracker-dbus.c 20 Sep 2006 05:52:05 -0000 @@ -48,7 +48,7 @@ connection = dbus_bus_get (DBUS_BUS_SESSION, &error); if ((connection == NULL) || dbus_error_is_set (&error)) { - tracker_log ("tracker_dbus_init() could not get the session bus"); + g_message ("tracker_dbus_init() could not get the session bus"); connection = NULL; goto out; } @@ -57,7 +57,7 @@ if (!dbus_connection_register_object_path (connection, TRACKER_OBJECT, &tracker_vtable, NULL)) { - tracker_log ("could not register D-BUS handlers"); + g_message ("could not register D-BUS handlers"); connection = NULL; goto out; } @@ -67,7 +67,7 @@ dbus_bus_request_name (connection, TRACKER_SERVICE, 0, &error); if (dbus_error_is_set (&error)) { - tracker_log ("could not acquire service name due to '%s'", error.message); + g_message ("could not acquire service name due to '%s'", error.message); connection = NULL; goto out; } Index: tracker-dbus-files.c =================================================================== RCS file: /cvs/gnome/tracker/src/trackerd/tracker-dbus-files.c,v retrieving revision 1.10 diff -u -d -r1.10 tracker-dbus-files.c --- tracker-dbus-files.c 9 Sep 2006 23:54:07 -0000 1.10 +++ tracker-dbus-files.c 20 Sep 2006 05:52:05 -0000 @@ -874,7 +874,7 @@ str = g_string_free (sql, FALSE); - tracker_log (str); + g_message (str); res = tracker_exec_sql (db_con, str); g_free (str); @@ -948,7 +948,7 @@ } } else { - tracker_log ("result set is empty"); + g_message ("result set is empty"); } tracker_db_free_result (res); @@ -1018,7 +1018,7 @@ } } else { - tracker_log ("result set is empty"); + g_message ("result set is empty"); } tracker_db_free_result (res); @@ -1089,7 +1089,7 @@ } } else { - tracker_log ("result set is empty"); + g_message ("result set is empty"); } tracker_db_free_result (res); Index: tracker-dbus-keywords.c =================================================================== RCS file: /cvs/gnome/tracker/src/trackerd/tracker-dbus-keywords.c,v retrieving revision 1.10 diff -u -d -r1.10 tracker-dbus-keywords.c --- tracker-dbus-keywords.c 13 Sep 2006 17:11:54 -0000 1.10 +++ tracker-dbus-keywords.c 20 Sep 2006 05:52:05 -0000 @@ -262,7 +262,7 @@ return; } - tracker_log ("adding keywords to %s with id %s", uri, id); + g_message ("adding keywords to %s with id %s", uri, id); g_free (id); @@ -501,7 +501,7 @@ g_string_append_printf (str_words, ", %s", array[i]); } - tracker_log ("executing keyword search on %s", str_words->str); + g_message ("executing keyword search on %s", str_words->str); g_string_free (str_words, TRUE); Index: tracker-dbus-metadata.c =================================================================== RCS file: /cvs/gnome/tracker/src/trackerd/tracker-dbus-metadata.c,v retrieving revision 1.8 diff -u -d -r1.8 tracker-dbus-metadata.c --- tracker-dbus-metadata.c 14 Sep 2006 11:48:09 -0000 1.8 +++ tracker-dbus-metadata.c 20 Sep 2006 05:52:05 -0000 @@ -267,7 +267,7 @@ str = g_string_free (sql, FALSE); - tracker_log (str); + g_message (str); res = tracker_exec_sql (db_con, str); @@ -307,7 +307,7 @@ } } else { - tracker_log ("result set is empty"); + g_message ("result set is empty"); array = g_new (char *, 1); Index: tracker-dbus-methods.c =================================================================== RCS file: /cvs/gnome/tracker/src/trackerd/tracker-dbus-methods.c,v retrieving revision 1.10 diff -u -d -r1.10 tracker-dbus-methods.c --- tracker-dbus-methods.c 16 Sep 2006 16:54:02 -0000 1.10 +++ tracker-dbus-methods.c 20 Sep 2006 05:52:05 -0000 @@ -43,10 +43,10 @@ msg); if (reply == NULL || !dbus_connection_send (rec->connection, reply, NULL)) { - tracker_log ("Warning - out of memory"); + g_message ("Warning - out of memory"); } - tracker_log ("The following error has happened : %s", msg); + g_message ("The following error has happened : %s", msg); g_free (msg); dbus_message_unref (reply); @@ -81,13 +81,13 @@ } } else { - tracker_log ("result set is empty"); + g_message ("result set is empty"); } tracker_db_free_result (res); } - tracker_log ("metadata %s is %s", key, value); + g_message ("metadata %s is %s", key, value); return value; } @@ -110,7 +110,7 @@ uri_in_locale = g_filename_from_utf8 (uri, -1, NULL, NULL, NULL); if (!uri_in_locale) { - tracker_log ("******ERROR**** info->uri could not be converted to locale format"); + g_message ("******ERROR**** info->uri could not be converted to locale format"); return -1; } @@ -243,7 +243,7 @@ } } else { - tracker_log ("result set is empty"); + g_message ("result set is empty"); } } @@ -297,7 +297,7 @@ db_con = rec->user_data; - tracker_log ("Executing GetServices Dbus Call"); + g_message ("Executing GetServices Dbus Call"); dbus_message_get_args (rec->message, NULL, DBUS_TYPE_BOOLEAN, &main_only, DBUS_TYPE_INVALID); @@ -343,7 +343,7 @@ db_con = rec->user_data; - tracker_log ("Executing GetStats Dbus Call"); + g_message ("Executing GetStats Dbus Call"); res = tracker_exec_proc (db_con, "GetStats", 0); Index: tracker-dbus-search.c =================================================================== RCS file: /cvs/gnome/tracker/src/trackerd/tracker-dbus-search.c,v retrieving revision 1.7 diff -u -d -r1.7 tracker-dbus-search.c --- tracker-dbus-search.c 16 Sep 2006 16:54:02 -0000 1.7 +++ tracker-dbus-search.c 20 Sep 2006 05:52:05 -0000 @@ -83,7 +83,7 @@ limit = 1024; } - tracker_log ("Executing search with params %s, %s", service, str); + g_message ("Executing search with params %s, %s", service, str); res = tracker_db_search_text (db_con, service, str, offset, limit, sort_results); @@ -112,7 +112,7 @@ } } else { - tracker_log ("search returned no results"); + g_message ("search returned no results"); } tracker_db_free_result (res); @@ -414,7 +414,7 @@ gboolean na; char *str, *search_term; - tracker_log ("executing rdf query %s\n", query); + g_message ("executing rdf query %s\n", query); search_term = tracker_format_search_terms (search_text, &na); @@ -440,9 +440,9 @@ } g_free (search_term); - tracker_log ("translated rdf query is %s\n", str); + g_message ("translated rdf query is %s\n", str); res = tracker_exec_sql_ignore_nulls (db_con, str); -// tracker_log_sql (db_con, str); +// g_message_sql (db_con, str); g_free (str); Index: trackerd.c =================================================================== RCS file: /cvs/gnome/tracker/src/trackerd/trackerd.c,v retrieving revision 1.35 diff -u -d -r1.35 trackerd.c --- trackerd.c 16 Sep 2006 16:54:02 -0000 1.35 +++ trackerd.c 20 Sep 2006 05:52:05 -0000 @@ -157,7 +157,7 @@ if (tracker->log_file) { - tracker_log ("Received signal '%s' so now shutting down", sig_msg); + g_message ("Received signal '%s' so now shutting down", sig_msg); } tracker_print_object_allocations (); @@ -189,7 +189,7 @@ g_mutex_unlock (tracker->metadata_signal_mutex); if (tracker->log_file) { - tracker_log ("shutting down threads"); + g_message ("shutting down threads"); } /* send signals to each thread to wake them up and then stop them */ @@ -234,7 +234,7 @@ tracker_db_finalize (); if (tracker->log_file) { - tracker_log ("shutting down main thread"); + g_message ("shutting down main thread"); } g_main_loop_quit (tracker->loop); @@ -264,7 +264,7 @@ char *str; str = *files_p; - tracker_log ("polling %s", str); + g_message ("polling %s", str); if (!tracker_file_is_valid (str)) { info = tracker_create_file_info (str, 1, 0, 0); @@ -315,7 +315,7 @@ if (g_slist_find_custom (tracker->no_watch_directory_list, uri, (GCompareFunc) has_prefix) == NULL) { scan_directory (uri, db_con); } else { - tracker_log ("blocked scan of directory %s as its in the no watch list", uri); + g_message ("blocked scan of directory %s as its in the no watch list", uri); } } @@ -325,7 +325,7 @@ { g_return_if_fail (db_con); - tracker_log ("polling dirs"); + g_message ("polling dirs"); if (g_slist_length (tracker->poll_list) > 0) { g_slist_foreach (tracker->poll_list, (GFunc) poll_dir, db_con); @@ -356,7 +356,7 @@ /* make thread sleep if first part of the shutdown process has been activated */ if (!tracker->is_running) { - tracker_log ("poll thread going to deep sleep..."); + g_message ("poll thread going to deep sleep..."); g_cond_wait (tracker->poll_thread_signal, tracker->poll_signal_mutex); @@ -371,9 +371,9 @@ poll_directories (db_con); /* sleep until notified again */ - tracker_log ("poll thread sleeping"); + g_message ("poll thread sleeping"); g_cond_wait (tracker->poll_thread_signal, tracker->poll_signal_mutex); - tracker_log ("poll thread awoken"); + g_message ("poll thread awoken"); /* determine if wake up call is a shutdown signal or a request to poll again */ if (!shutdown) { @@ -386,7 +386,7 @@ tracker_db_close (db_con); tracker_db_thread_end (); - tracker_log ("poll thread has exited successfully"); + g_message ("poll thread has exited successfully"); g_mutex_unlock (tracker->poll_stopped_mutex); } @@ -397,7 +397,7 @@ { if (!tracker->file_poll_thread && g_slist_length (tracker->poll_list) > 0) { tracker->file_poll_thread = g_thread_create ((GThreadFunc) poll_files_thread, NULL, FALSE, NULL); - tracker_log ("started polling"); + g_message ("started polling"); } else { /* wake up poll thread and start polling */ @@ -409,7 +409,7 @@ } } - return TRUE; + return FALSE; } @@ -488,7 +488,7 @@ dir_utf8 = g_filename_to_utf8 (dir, -1, NULL,NULL,NULL); if (!dir_utf8) { - tracker_log ("******ERROR**** watch_dir could not be converted to utf8 format"); + g_message ("******ERROR**** watch_dir could not be converted to utf8 format"); return FALSE; } } else { @@ -572,7 +572,7 @@ default: if (tracker->log_file) { - tracker_log ("Received signal %s ", g_strsignal (signo)); + g_message ("Received signal %s ", g_strsignal (signo)); } in_loop = FALSE; break; @@ -593,7 +593,7 @@ tracker_db_delete_file (db_con, info->file_id); - tracker_log ("deleting file %s", info->uri); + g_message ("deleting file %s", info->uri); } @@ -614,7 +614,7 @@ tracker_remove_poll_dir (info->uri); - tracker_log ("deleting directory %s and subdirs", info->uri); + g_message ("deleting directory %s and subdirs", info->uri); } @@ -634,14 +634,14 @@ g_return_if_fail (tracker_file_info_is_valid (info)); if (!tracker_file_is_valid (info->uri)) { - tracker_log ("Warning - file %s no longer exists - abandoning index on this file", info->uri); + g_message ("Warning - file %s no longer exists - abandoning index on this file", info->uri); return; } /* refresh DB data as previous stuff might be out of date by the time we get here */ info = tracker_db_get_file_info (db_con, info); - tracker_log ("indexing file %s", info->uri); + g_message ("indexing file %s", info->uri); meta_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); @@ -694,7 +694,7 @@ } tracker_db_create_service (db_con, path, name, service_name, info->is_directory, info->is_link, FALSE, 0, info->mtime); - //tracker_log ("processed file %s with mime %s and service %s", info->uri, info->mime, service_name); + //g_message ("processed file %s with mime %s and service %s", info->uri, info->mime, service_name); g_free (service_name); @@ -702,7 +702,7 @@ } else { - tracker_log ("updating file %s ", info->uri); + g_message ("updating file %s ", info->uri); tracker_db_update_file (db_con, info->file_id, info->mtime); @@ -730,7 +730,7 @@ } if (info->file_id == -1) { - tracker_log ("FILE %s NOT FOUND IN DB!", info->uri); + g_message ("FILE %s NOT FOUND IN DB!", info->uri); } } @@ -750,7 +750,7 @@ str = (char *) tmp->data; if (g_slist_find_custom (tracker->no_watch_directory_list, str, (GCompareFunc) has_prefix) == NULL) { - tracker_log ("removing %s from scan list", str); + g_message ("removing %s from scan list", str); list = g_slist_remove (list, str); g_free (str); str = NULL; @@ -812,7 +812,7 @@ } if (!tracker_start_watching ()) { - tracker_log ("File monitoring failed to start"); + g_message ("File monitoring failed to start"); do_cleanup ("File watching failure"); exit (1); } else { @@ -838,7 +838,7 @@ g_slist_foreach (tracker->watch_directory_roots_list, (GFunc) schedule_file_check, main_thread_db_con); } - tracker_log ("waiting for file events..."); + g_message ("waiting for file events..."); } return FALSE; @@ -873,7 +873,7 @@ /* make thread sleep if first part of the shutdown process has been activated */ if (!tracker->is_running) { - tracker_log ("metadata thread going to deep sleep..."); + g_message ("metadata thread going to deep sleep..."); g_cond_wait (tracker->metadata_thread_signal, tracker->metadata_signal_mutex); @@ -898,12 +898,12 @@ if (tracker_db_has_pending_metadata (db_con)) { g_mutex_unlock (tracker->metadata_check_mutex); } else { - //tracker_log ("metadata thread sleeping"); + //g_message ("metadata thread sleeping"); /* we have no stuff to process so sleep until awoken by a new signal */ g_cond_wait (tracker->metadata_thread_signal, tracker->metadata_signal_mutex); g_mutex_unlock (tracker->metadata_check_mutex); - //tracker_log ("metadata thread awoken"); + //g_message ("metadata thread awoken"); /* determine if wake up call is new stuff or a shutdown signal */ if (!shutdown) { continue; @@ -954,7 +954,7 @@ GHashTable *meta_table; char *file_as_text; - tracker_log ("Extracting Metadata for file %s with mime %s", info->uri, info->mime); + g_message ("Extracting Metadata for file %s with mime %s", info->uri, info->mime); /* refresh stat data in case its changed */ info = tracker_get_file_info (info); @@ -1006,7 +1006,7 @@ const char *tmp_dir; char *dir; - //tracker_log ("text file is %s", file_as_text); + //g_message ("text file is %s", file_as_text); /* to do - we need a setting for an upper limit to how much text we read in */ tracker_db_save_file_contents (db_con, file_as_text, info); @@ -1033,7 +1033,7 @@ tracker_db_close (db_con); tracker_db_thread_end (); - tracker_log ("metadata thread has exited successfully"); + g_message ("metadata thread has exited successfully"); g_mutex_unlock (tracker->metadata_stopped_mutex); } @@ -1131,7 +1131,7 @@ /* make thread sleep if first part of the shutdown process has been activated */ if (!tracker->is_running) { - tracker_log ("files thread going to deep sleep..."); + g_message ("files thread going to deep sleep..."); g_cond_wait (tracker->file_thread_signal, tracker->files_signal_mutex); @@ -1157,13 +1157,13 @@ if (tracker_db_has_pending_files (db_con)) { g_mutex_unlock (tracker->files_check_mutex); } else { - //tracker_log ("File thread sleeping"); + //g_message ("File thread sleeping"); /* we have no stuff to process so sleep until awoken by a new signal */ g_cond_wait (tracker->file_thread_signal, tracker->files_signal_mutex); g_mutex_unlock (tracker->files_check_mutex); - //tracker_log ("File thread awoken"); + //g_message ("File thread awoken"); /* determine if wake up call is new stuff or a shutdown signal */ if (!shutdown) { @@ -1195,7 +1195,7 @@ if (tmp_action != TRACKER_ACTION_CHECK) { - tracker_log ("processing %s with event %s", row[1], tracker_actions[tmp_action]); + g_message ("processing %s with event %s", row[1], tracker_actions[tmp_action]); } info_tmp = tracker_create_file_info (row[1], tmp_action, 0, WATCH_OTHER); @@ -1215,7 +1215,7 @@ /* pending files are present but not yet ready as we are waiting til they stabilize so we should sleep for 100ms (only occurs when using FAM) */ if (k == 0) { - tracker_log ("files not ready so sleeping"); + g_message ("files not ready so sleeping"); g_usleep (100000); } @@ -1228,7 +1228,7 @@ continue; } - //tracker_log ("processing %s with action %s and counter %d ", info->uri, tracker_actions[info->action], info->counter); + //g_message ("processing %s with action %s and counter %d ", info->uri, tracker_actions[info->action], info->counter); /* get file ID and other interesting fields from Database if not previously fetched or is newly created */ @@ -1248,7 +1248,7 @@ /* preprocess ambiguous actions when we need to work out if its a file or a directory that the action relates to */ verify_action (info); - //tracker_log ("processing %s with action %s and counter %d ", info->uri, tracker_actions[info->action], info->counter); + //g_message ("processing %s with action %s and counter %d ", info->uri, tracker_actions[info->action], info->counter); /* process deletions */ @@ -1317,7 +1317,7 @@ if (g_slist_find_custom (tracker->no_watch_directory_list, info->uri, (GCompareFunc) has_prefix) == NULL) { scan_directory (info->uri, db_con); } else { - tracker_log ("blocked scan of directory %s as its in the no watch list", info->uri); + g_message ("blocked scan of directory %s as its in the no watch list", info->uri); } } @@ -1328,7 +1328,7 @@ if (g_slist_find_custom (tracker->no_watch_directory_list, info->uri, (GCompareFunc) has_prefix) == NULL) { scan_directory (info->uri, db_con); } else { - tracker_log ("blocked scan of directory %s as its in the no watch list", info->uri); + g_message ("blocked scan of directory %s as its in the no watch list", info->uri); } break; @@ -1337,7 +1337,7 @@ case TRACKER_ACTION_DIRECTORY_MOVED_TO: need_index = TRUE; - tracker_log ("processing created directory %s", info->uri); + g_message ("processing created directory %s", info->uri); /* add to watch folders (including subfolders) */ watch_dir (info->uri, db_con); @@ -1347,7 +1347,7 @@ if (g_slist_find_custom (tracker->no_watch_directory_list, info->uri, (GCompareFunc) has_prefix) == NULL) { scan_directory (info->uri, db_con); } else { - tracker_log ("blocked scan of directory %s as its in the no watch list", info->uri); + g_message ("blocked scan of directory %s as its in the no watch list", info->uri); } } @@ -1366,7 +1366,7 @@ tracker_db_close (db_con); tracker_db_thread_end (); - tracker_log ("files thread has exited successfully"); + g_message ("files thread has exited successfully"); g_mutex_unlock (tracker->files_stopped_mutex); } @@ -1400,7 +1400,7 @@ /* make thread sleep if first part of the shutdown process has been activated */ if (!tracker->is_running) { - tracker_log ("request thread going to deep sleep..."); + g_message ("request thread going to deep sleep..."); g_cond_wait (tracker->request_thread_signal, tracker->request_signal_mutex); @@ -1418,10 +1418,10 @@ rec = g_async_queue_try_pop (tracker->user_request_queue); if (!rec) { - tracker_log ("request thread sleeping"); + g_message ("request thread sleeping"); g_cond_wait (tracker->request_thread_signal, tracker->request_signal_mutex); g_mutex_unlock (tracker->request_check_mutex); - tracker_log ("request thread awoken"); + g_message ("request thread awoken"); /* determine if wake up call is new stuff or a shutdown signal */ if (!shutdown) { @@ -1691,7 +1691,7 @@ tracker_db_close (db_con); tracker_db_thread_end (); - tracker_log ("request thread has exited successfully"); + g_message ("request thread has exited successfully"); /* unlock mutex so we know thread has exited */ g_mutex_unlock (tracker->request_check_mutex); @@ -1715,7 +1715,7 @@ if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected")) { dbus_message_ref (message); - tracker_log ("DBus connection has been lost, trackerd will shutdown"); + g_message ("DBus connection has been lost, trackerd will shutdown"); tracker->is_running = FALSE; tracker_end_watching (); @@ -1739,7 +1739,7 @@ }; if (!dbus_connection_register_object_path (connection, DBUS_PATH_LOCAL, &dbus_daemon_vtable, NULL)) { - tracker_log ("could not register local D-BUS connection handler"); + g_message ("could not register local D-BUS connection handler"); return FALSE; } else { @@ -1763,6 +1763,53 @@ } +void +log_handler (const gchar *domain, GLogLevelFlags levels, const char* message, gpointer data) +{ + FILE *fd; + time_t now; + char buffer1[64], buffer2[20]; + char *output; + char *msg; + va_list args; + struct tm *loctime; + GTimeVal start; + + if (message) { + g_print ("%s\n", message); + } + + /* ensure file logging is thread safe */ + g_mutex_lock (tracker->log_access_mutex); + + fd = g_fopen (tracker->log_file, "a"); + + if (!fd) { + g_mutex_unlock (tracker->log_access_mutex); + g_warning ("could not open %s", tracker->log_file); + return; + } + + g_get_current_time (&start); + + now = time ((time_t *) NULL); + + loctime = localtime (&now); + + strftime (buffer1, 64, "%d %b %Y, %H:%M:%S:", loctime); + + g_sprintf (buffer2, "%ld", start.tv_usec / 1000); + + output = g_strconcat (buffer1, buffer2, " - ", message, NULL); + + g_fprintf (fd, "%s\n", output); + g_free (output); + + fclose (fd); + + g_mutex_unlock (tracker->log_access_mutex); +} + int main (int argc, char **argv) @@ -1792,6 +1839,8 @@ g_thread_init (NULL); } + g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, (GLogFunc) log_handler, NULL); + dbus_g_thread_init (); need_setup = FALSE; @@ -1919,7 +1968,7 @@ tracker_data_dir = g_build_filename (g_get_home_dir (), ".Tracker", "data", NULL); if (!tracker_db_initialize (tracker_data_dir)) { - tracker_log ("Failed to initialise database engine - exiting..."); + g_message ("Failed to initialise database engine - exiting..."); return 1; } @@ -1963,8 +2012,8 @@ char **row; int k; - tracker_log ("-----------------------"); - tracker_log ("Fetching index stats..."); + g_message ("-----------------------"); + g_message ("Fetching index stats..."); k = 0; @@ -1973,14 +2022,14 @@ k++; if (row && row[0] && row[1]) { - tracker_log ("%s : %s", row[0], row[1]); + g_message ("%s : %s", row[0], row[1]); } } tracker_db_free_result (res); } - tracker_log ("-----------------------\n"); + g_message ("-----------------------\n"); } @@ -2041,7 +2090,7 @@ g_main_loop_run (tracker->loop); /* the following should never be reached in practice */ - tracker_log ("we should never get this message"); + g_message ("we should never get this message"); tracker_db_close (db_con); Index: tracker-fam.c =================================================================== RCS file: /cvs/gnome/tracker/src/trackerd/tracker-fam.c,v retrieving revision 1.11 diff -u -d -r1.11 tracker-fam.c --- tracker-fam.c 9 Sep 2006 23:54:08 -0000 1.11 +++ tracker-fam.c 20 Sep 2006 05:52:05 -0000 @@ -196,7 +196,7 @@ g_free (file_uri); if (!file_utf8_uri) { - tracker_log ("******ERROR**** FAM file uri could not be converted to utf8 format"); + g_message ("******ERROR**** FAM file uri could not be converted to utf8 format"); continue; } @@ -211,7 +211,7 @@ uri_in_locale = g_filename_from_utf8 (info->uri, -1, NULL, NULL, NULL); if (!uri_in_locale) { - tracker_log ("******ERROR**** FAM uri could not be converted to locale format"); + g_message ("******ERROR**** FAM uri could not be converted to locale format"); return FALSE; } @@ -277,14 +277,14 @@ if (g_hash_table_size (watch_table) >= MAX_FILE_WATCHES) { - tracker_log ("Watch Limit has been exceeded - unable to watch any more directories"); + g_message ("Watch Limit has been exceeded - unable to watch any more directories"); return FALSE; } dir_in_locale = g_filename_from_utf8 (dir, -1, NULL, NULL, NULL); if (!dir_in_locale) { - tracker_log ("******ERROR**** FAM dir could not be converted to locale format"); + g_message ("******ERROR**** FAM dir could not be converted to locale format"); return FALSE; } @@ -302,12 +302,12 @@ rc = FAMMonitorDirectory (&fc, dir_in_locale, fr, fwatch); if (rc > 0) { - tracker_log ("FAM watch on %s has failed", dir); + g_message ("FAM watch on %s has failed", dir); free_watch_func (fwatch); return FALSE; } else { g_hash_table_insert (watch_table, g_strdup (dir), fwatch); - tracker_log ("Watching directory %s (total watches = %d)", dir, g_hash_table_size (watch_table)); + g_message ("Watching directory %s (total watches = %d)", dir, g_hash_table_size (watch_table)); return TRUE; } } Index: tracker-indexer.c =================================================================== RCS file: /cvs/gnome/tracker/src/trackerd/tracker-indexer.c,v retrieving revision 1.7 diff -u -d -r1.7 tracker-indexer.c --- tracker-indexer.c 18 Sep 2006 10:39:29 -0000 1.7 +++ tracker-indexer.c 20 Sep 2006 05:52:05 -0000 @@ -165,7 +165,7 @@ base_dir = g_build_filename (g_get_home_dir(), ".Tracker", "Indexes", NULL); word_index_name = g_strconcat (base_dir, "/words/", name, NULL); - tracker_log ("Word index is %s", word_index_name); + g_message ("Word index is %s", word_index_name); if (!tracker_file_is_valid (word_index_name)) { g_mkdir_with_parents (word_index_name, 00755); @@ -174,7 +174,7 @@ word_index = dpopen (word_index_name, DP_OWRITER | DP_OCREAT | DP_ONOLCK, INDEXBNUM); if (!word_index) { - tracker_log ("word index was not closed properly - attempting repair"); + g_message ("word index was not closed properly - attempting repair"); if (dprepair (word_index_name)) { word_index = dpopen (word_index_name, DP_OWRITER | DP_OCREAT | DP_ONOLCK, INDEXBNUM); } else { @@ -201,7 +201,7 @@ records = dprnum (result->word_index); if ((buckets < (2 * records)) || (dpfsiz (result->word_index) > COMPACT_AT_SIZE)) { - tracker_log ("Optimizing word index - this may take a while..."); + g_message ("Optimizing word index - this may take a while..."); tracker_indexer_optimize (result->word_index); } @@ -247,7 +247,7 @@ g_return_val_if_fail ((indexer && word), FALSE); - tracker_log ("inserting word %s with score %d into Service ID %d and service type %d", + g_message ("inserting word %s with score %d into Service ID %d and service type %d", word, score, service_id, Index: tracker-inotify.c =================================================================== RCS file: /cvs/gnome/tracker/src/trackerd/tracker-inotify.c,v retrieving revision 1.14 diff -u -d -r1.14 tracker-inotify.c --- tracker-inotify.c 11 Sep 2006 13:14:57 -0000 1.14 +++ tracker-inotify.c 20 Sep 2006 05:52:05 -0000 @@ -33,42 +33,42 @@ /* list to temporarily store moved_from events so they can be matched against moved_to events */ static GSList *move_list; static GQueue *inotify_queue; -static int inotify_monitor_fd = -1; -static int inotify_count = 0; +static int inotify_monitor_fd = -1; +static int inotify_count = 0; static GIOChannel *gio; +static gboolean process_moved_events (); + + gboolean tracker_is_directory_watched (const char * dir, DBConnection *db_con) { char ***res; + char **row; - if (!tracker->is_running) { - return FALSE; - } + g_return_val_if_fail (dir != NULL && dir[0] == G_DIR_SEPARATOR, FALSE); - if (!dir || strlen (dir) == 0 || dir[0] != G_DIR_SEPARATOR) { + if (!tracker->is_running) { return FALSE; } res = tracker_exec_proc (db_con, "GetWatchID", 1, dir); - if (res) { - char **row; - - row = tracker_db_get_row (res, 0); + if (!res) { + return FALSE; + } - if (row && row[0]) { - if (atoi (row[0]) > -1) { - return TRUE; - } - } + row = tracker_db_get_row (res, 0); + if (!row || !row[0] || atoi (row[0]) < 0) { tracker_db_free_result (res); + return FALSE; } - return FALSE; + tracker_db_free_result (res); + return TRUE; } @@ -88,9 +88,7 @@ { char *prefix_start, *str; - if (source == NULL) { - return NULL; - } + g_return_val_if_fail (source != NULL, NULL); if (delimiter == NULL) { return g_strdup (source); @@ -116,202 +114,214 @@ info = tracker_create_file_info (uri, action, 1, WATCH_OTHER); - if (tracker_file_info_is_valid (info)) { - info->is_directory = is_dir; + if (!tracker_file_info_is_valid (info)) { + return; + } - if (is_delete_event (action)) { - char *parent; + info->is_directory = is_dir; - parent = g_path_get_dirname (info->uri); + if (is_delete_event (action)) { + char *parent; - if (tracker_file_is_valid (parent)) { - g_async_queue_push (tracker->file_process_queue, info); + parent = g_path_get_dirname (info->uri); - tracker_notify_file_data_available (); - } else { - info = tracker_free_file_info (info); - } + if (tracker_file_is_valid (parent)) { + g_async_queue_push (tracker->file_process_queue, info); + tracker_notify_file_data_available (); + } else { + info = tracker_free_file_info (info); + } - if (parent) { - g_free (parent); - } + g_free (parent); + return; + } - return; - } + /* we are not interested in create events for non-folders (we use writable file closed instead) */ + if (action == TRACKER_ACTION_DIRECTORY_CREATED) { - /* we are not interested in create events for non-folders (we use writable file closed instead) */ - if (action == TRACKER_ACTION_DIRECTORY_CREATED) { - info->action = TRACKER_ACTION_DIRECTORY_CREATED; - info->is_directory = TRUE; - tracker_db_insert_pending_file (main_thread_db_con, info->file_id, info->uri, info->mime, 0, info->action, info->is_directory); - info = tracker_free_file_info (info); - return; + info->action = TRACKER_ACTION_DIRECTORY_CREATED; + info->is_directory = TRUE; + tracker_db_insert_pending_file (main_thread_db_con, info->file_id, info->uri, info->mime, 0, info->action, info->is_directory); + info = tracker_free_file_info (info); + return; - } else if (action == TRACKER_ACTION_FILE_CREATED) { - info = tracker_free_file_info (info); - return; + } else if (action == TRACKER_ACTION_FILE_CREATED) { - } else if (action == TRACKER_ACTION_DIRECTORY_MOVED_FROM || action == TRACKER_ACTION_FILE_MOVED_FROM) { - info->cookie = cookie; - info->counter = 1; - move_list = g_slist_prepend (move_list, info); - return; + info = tracker_free_file_info (info); + return; - } else if (action == TRACKER_ACTION_FILE_MOVED_TO || action == TRACKER_ACTION_DIRECTORY_MOVED_TO) { - FileInfo *moved_to_info; - GSList *tmp; + } else if (action == TRACKER_ACTION_DIRECTORY_MOVED_FROM || action == TRACKER_ACTION_FILE_MOVED_FROM) { - moved_to_info = info; + info->cookie = cookie; + info->counter = 1; + move_list = g_slist_prepend (move_list, info); + g_timeout_add_full (G_PRIORITY_LOW, + 350, + (GSourceFunc) process_moved_events, + NULL, NULL + ); + return; - for (tmp = move_list; tmp; tmp = tmp->next) { - FileInfo *moved_from_info; + } else if (action == TRACKER_ACTION_FILE_MOVED_TO || action == TRACKER_ACTION_DIRECTORY_MOVED_TO) { + FileInfo *moved_to_info; + GSList *tmp; - moved_from_info = (FileInfo *) tmp->data; + moved_to_info = info; - if (!moved_from_info) { - tracker_log ("bad FileInfo struct found in move list. Skipping..."); - continue; - } + for (tmp = move_list; tmp; tmp = tmp->next) { + FileInfo *moved_from_info; - if ((cookie > 0) && (moved_from_info->cookie == cookie)) { - char *str_file_id, *name, *path; + moved_from_info = (FileInfo *) tmp->data; - tracker_log ("found matching inotify pair for from %s to %s", moved_from_info->uri, moved_to_info->uri); - move_list = g_slist_remove (move_list, tmp->data); + if (!moved_from_info) { + g_message ("bad FileInfo struct found in move list. Skipping..."); + continue; + } - moved_from_info = tracker_db_get_file_info (main_thread_db_con, moved_from_info); + if ((cookie > 0) && (moved_from_info->cookie == cookie)) { + char *str_file_id, *name, *path; - /* if orig file not in DB, treat it as a create action */ - if (moved_from_info->file_id == -1) { - tracker_log ("warning original file %s not found in DB", moved_from_info->uri); - break; - } + g_message ("found matching inotify pair for from %s to %s", moved_from_info->uri, moved_to_info->uri); + move_list = g_slist_remove (move_list, tmp->data); - str_file_id = g_strdup_printf ("%ld", moved_from_info->file_id); - name = g_path_get_basename (moved_to_info->uri); - path = g_path_get_dirname (moved_to_info->uri); + moved_from_info = tracker_db_get_file_info (main_thread_db_con, moved_from_info); - /* update db so that fileID reflects new uri */ - tracker_db_update_file_move (main_thread_db_con, moved_from_info->file_id, path, name, moved_from_info->indextime); + /* if orig file not in DB, treat it as a create action */ + if (moved_from_info->file_id == -1) { + g_message ("warning original file %s not found in DB", moved_from_info->uri); + break; + } - /* update File.Path and File.Filename metadata */ - tracker_db_set_metadata (main_thread_db_con, "Files", str_file_id, "File.Path", path, TRUE); - tracker_db_set_metadata (main_thread_db_con, "Files", str_file_id, "File.Name", name, TRUE); + str_file_id = g_strdup_printf ("%ld", moved_from_info->file_id); + name = g_path_get_basename (moved_to_info->uri); + path = g_path_get_dirname (moved_to_info->uri); - g_free (str_file_id); - g_free (name); - g_free (path); + /* update db so that fileID reflects new uri */ + tracker_db_update_file_move (main_thread_db_con, moved_from_info->file_id, path, name, moved_from_info->indextime); - if (tracker_is_directory (moved_to_info->uri)) { - char *modified_path, *old_path, *match_path; - char ***res; + /* update File.Path and File.Filename metadata */ + tracker_db_set_metadata (main_thread_db_con, "Files", str_file_id, "File.Path", path, TRUE); + tracker_db_set_metadata (main_thread_db_con, "Files", str_file_id, "File.Name", name, TRUE); - /* update all childs of the moved directory */ - modified_path = g_strconcat (moved_to_info->uri, G_DIR_SEPARATOR_S, NULL); - old_path = g_strconcat (moved_from_info->uri, G_DIR_SEPARATOR_S, NULL); - match_path = g_strconcat (old_path, "%", NULL); + g_free (str_file_id); + g_free (name); + g_free (path); - tracker_log ("moved file is a dir"); + if (tracker_is_directory (moved_to_info->uri)) { + char *modified_path, *old_path, *match_path; + char ***res; - /* stop watching old dir, start watching new dir */ - tracker_remove_watch_dir (moved_from_info->uri, TRUE, main_thread_db_con); - tracker_remove_poll_dir (moved_from_info->uri); + /* update all childs of the moved directory */ + modified_path = g_strconcat (moved_to_info->uri, G_DIR_SEPARATOR_S, NULL); + old_path = g_strconcat (moved_from_info->uri, G_DIR_SEPARATOR_S, NULL); + match_path = g_strconcat (old_path, "%", NULL); - if (tracker_count_watch_dirs () < MAX_FILE_WATCHES) { - tracker_add_watch_dir (moved_to_info->uri, main_thread_db_con); - } else { - tracker_add_poll_dir (moved_to_info->uri); - } + g_message ("moved file is a dir"); - /* update all changed File.Path metadata */ - tracker_exec_proc (main_thread_db_con, "UpdateFileMovePath", 2, moved_to_info->uri, moved_from_info->uri); + /* stop watching old dir, start watching new dir */ + tracker_remove_watch_dir (moved_from_info->uri, TRUE, main_thread_db_con); + tracker_remove_poll_dir (moved_from_info->uri); + if (tracker_count_watch_dirs () < MAX_FILE_WATCHES) { + tracker_add_watch_dir (moved_to_info->uri, main_thread_db_con); + } else { + tracker_add_poll_dir (moved_to_info->uri); + } - /* for each subfolder, we must do the same as above */ + /* update all changed File.Path metadata */ + tracker_exec_proc (main_thread_db_con, "UpdateFileMovePath", 2, moved_to_info->uri, moved_from_info->uri); - /* get all sub folders that were moved and add watches */ - res = tracker_db_get_file_subfolders (main_thread_db_con, moved_from_info->uri); - if (res) { - char **row; - int k; + /* for each subfolder, we must do the same as above */ - k = 0; + /* get all sub folders that were moved and add watches */ + res = tracker_db_get_file_subfolders (main_thread_db_con, moved_from_info->uri); - while ((row = tracker_db_get_row (res, k))) { + if (res) { + char **row; + int k; - k++; - if (row && row[0] && row[1] && row[2]) { - char *dir_name, *sep; + k = 0; - dir_name = g_build_filename (row[1], row[2], NULL); + while ((row = tracker_db_get_row (res, k))) { - sep = str_get_after_prefix (dir_name, old_path); + char *dir_name, *sep, *new_path; + k++; - if (sep) { - char *new_path; + if (!row || !row[0] || !row[1] || !row[2]) { + continue; + } - new_path = g_build_filename (moved_to_info->uri, sep, NULL); - g_free (sep); + dir_name = g_build_filename (row[1], row[2], NULL); - tracker_log ("moving subfolder %s to %s", dir_name, new_path); + sep = str_get_after_prefix (dir_name, old_path); - /* update all changed File.Path metadata for all files in this subfolder*/ - tracker_exec_proc (main_thread_db_con, "UpdateFileMovePath", 2, new_path, dir_name); + if (!sep) { + g_free (dir_name); + continue; + } - /* update all subfolders and contained files to new path */ - tracker_exec_proc (main_thread_db_con, "UpdateFileMoveChild", 2, new_path, dir_name); + new_path = g_build_filename (moved_to_info->uri, sep, NULL); + g_free (sep); - if (tracker_count_watch_dirs () < MAX_FILE_WATCHES) { - tracker_add_watch_dir (new_path, main_thread_db_con); - } else { - tracker_add_poll_dir (new_path); - } - g_free (new_path); - g_free (dir_name); - } - } + g_message ("moving subfolder %s to %s", dir_name, new_path); + + /* update all changed File.Path metadata for all files in this subfolder*/ + tracker_exec_proc (main_thread_db_con, "UpdateFileMovePath", 2, new_path, dir_name); + + /* update all subfolders and contained files to new path */ + tracker_exec_proc (main_thread_db_con, "UpdateFileMoveChild", 2, new_path, dir_name); + + if (tracker_count_watch_dirs () < MAX_FILE_WATCHES) { + tracker_add_watch_dir (new_path, main_thread_db_con); + } else { + tracker_add_poll_dir (new_path); } + g_free (new_path); + g_free (dir_name); - tracker_db_free_result (res); } - /* update uri path of all files in moved folder */ - tracker_exec_proc (main_thread_db_con, "UpdateFileMoveChild", 2, moved_to_info->uri, moved_from_info->uri); - - g_free (modified_path); - g_free (old_path); - g_free (match_path); + tracker_db_free_result (res); } - moved_from_info = tracker_free_file_info (moved_from_info); - moved_to_info = tracker_free_file_info (moved_to_info); - info = NULL; - return; + /* update uri path of all files in moved folder */ + tracker_exec_proc (main_thread_db_con, "UpdateFileMoveChild", 2, moved_to_info->uri, moved_from_info->uri); + + g_free (modified_path); + g_free (old_path); + g_free (match_path); } - } - /* matching pair not found so treat as a create action */ - tracker_log ("no matching pair found for inotify move event"); - if (tracker_is_directory (info->uri)) { - info->action = TRACKER_ACTION_DIRECTORY_CREATED; - } else { - info->action = TRACKER_ACTION_FILE_CREATED; + moved_from_info = tracker_free_file_info (moved_from_info); + moved_to_info = tracker_free_file_info (moved_to_info); + info = NULL; + return; } - tracker_db_insert_pending_file (main_thread_db_con, info->file_id, info->uri, info->mime, 0, info->action, info->is_directory); - info = tracker_free_file_info (info); - return; + } - } else if (action == TRACKER_ACTION_WRITABLE_FILE_CLOSED) { - //tracker_log ("File %s has finished changing", info->uri); - tracker_db_insert_pending_file (main_thread_db_con, info->file_id, info->uri, info->mime, 0, info->action, info->is_directory); - info = tracker_free_file_info (info); - return; + /* matching pair not found so treat as a create action */ + g_message ("no matching pair found for inotify move event"); + if (tracker_is_directory (info->uri)) { + info->action = TRACKER_ACTION_DIRECTORY_CREATED; + } else { + info->action = TRACKER_ACTION_FILE_CREATED; } + tracker_db_insert_pending_file (main_thread_db_con, info->file_id, info->uri, info->mime, 0, info->action, info->is_directory); + info = tracker_free_file_info (info); + return; + + } else if (action == TRACKER_ACTION_WRITABLE_FILE_CLOSED) { + + //g_message ("File %s has finished changing", info->uri); + tracker_db_insert_pending_file (main_thread_db_con, info->file_id, info->uri, info->mime, 0, info->action, info->is_directory); + info = tracker_free_file_info (info); + return; - tracker_log ("not processing event %s for uri %s", tracker_actions[info->action], info->uri); - tracker_free_file_info (info); } + + g_message ("not processing event %s for uri %s", tracker_actions[info->action], info->uri); + tracker_free_file_info (info); } @@ -339,7 +349,6 @@ /* make sure file no longer exists before issuing a "delete" */ if (!tracker_file_is_valid (info->uri)) { - if (info->action == TRACKER_ACTION_DIRECTORY_MOVED_FROM) { process_event (info->uri, TRUE, TRACKER_ACTION_DIRECTORY_DELETED, 0); } else { @@ -356,6 +365,9 @@ } } + if (!move_list) + return FALSE; + return TRUE; } @@ -413,16 +425,6 @@ return TRACKER_ACTION_IGNORE; } - -static void -free_inotify_event (struct inotify_event *event) -{ - g_return_if_fail (event); - - g_free (event); -} - - static gboolean process_inotify_events (void) { @@ -472,7 +474,7 @@ monitor_name = g_strdup (row[0]); } else { monitor_name = NULL; - free_inotify_event (event); + g_free (event); continue; } @@ -480,22 +482,22 @@ } if (action_type == TRACKER_ACTION_IGNORE) { - free_inotify_event (event); - //tracker_log ("inotify event has no action"); + g_free (event); + //g_message ("inotify event has no action"); continue; } if ( !filename || strlen(filename) == 0) { - //tracker_log ("inotify event has no filename"); - free_inotify_event (event); + //g_message ("inotify event has no filename"); + g_free (event); continue; } file_utf8_uri = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL); if (!file_utf8_uri || strlen(file_utf8_uri) == 0) { - tracker_log ("******ERROR**** file uri could not be converted to utf8 format"); - free_inotify_event (event); + g_message ("******ERROR**** file uri could not be converted to utf8 format"); + g_free (event); continue; } @@ -506,9 +508,9 @@ dir_utf8_uri = g_filename_to_utf8 (monitor_name, -1, NULL, NULL, NULL); if (!dir_utf8_uri) { - tracker_log ("******ERROR**** file uri could not be converted to utf8 format"); + g_message ("******ERROR**** file uri could not be converted to utf8 format"); g_free (file_utf8_uri); - free_inotify_event (event); + g_free (event); continue; } @@ -521,23 +523,11 @@ } - if (monitor_name) { - g_free (monitor_name); - } - - if (str) { - g_free (str); - } - - if (file_utf8_uri) { - g_free (file_utf8_uri); - } - - if (dir_utf8_uri) { - g_free (dir_utf8_uri); - } - - free_inotify_event (event); + g_free (monitor_name); + g_free (str); + g_free (file_utf8_uri); + g_free (dir_utf8_uri); + g_free (event); } return FALSE; @@ -557,7 +547,7 @@ r = read (fd, buffer, 16384); if (r <= 0) { - tracker_log ("inotify system failure - unable to watch files"); + g_message ("inotify system failure - unable to watch files"); return FALSE; } @@ -575,8 +565,7 @@ pevent = (struct inotify_event *) &buffer[buffer_i]; event_size = sizeof (struct inotify_event) + pevent->len; - event = g_malloc (event_size); - memmove (event, pevent, event_size); + event = g_memdup (pevent, event_size); g_queue_push_tail (inotify_queue, event); buffer_i += event_size; } @@ -590,15 +579,11 @@ gboolean tracker_start_watching (void) { - if (inotify_monitor_fd != -1) { - return FALSE; - } + g_return_val_if_fail (inotify_monitor_fd == -1, FALSE); inotify_monitor_fd = inotify_init (); - if (inotify_monitor_fd < 0) { - return FALSE; - } + g_return_val_if_fail (inotify_monitor_fd >= 0, FALSE); inotify_queue = g_queue_new (); @@ -607,11 +592,6 @@ g_io_channel_set_flags (gio, G_IO_FLAG_NONBLOCK, NULL); /* periodically process unmatched moved_from events */ - g_timeout_add_full (G_PRIORITY_LOW, - 350, - (GSourceFunc) process_moved_events, - NULL, NULL - ); return TRUE; } @@ -629,16 +609,14 @@ { char *dir_in_locale; - if (!tracker->is_running) { - return FALSE; - } + g_return_val_if_fail (dir != NULL && dir[0] == G_DIR_SEPARATOR, FALSE); - if (!dir || strlen (dir) == 0 || dir[0] != G_DIR_SEPARATOR) { + if (!tracker->is_running) { return FALSE; } if (tracker_count_watch_dirs () >= MAX_FILE_WATCHES) { - tracker_log ("Inotify Watch Limit has been exceeded - unable to watch any more directories"); + g_message ("Inotify Watch Limit has been exceeded - unable to watch any more directories"); return FALSE; } @@ -648,24 +626,23 @@ if (g_access (dir_in_locale, F_OK) == 0 && g_access (dir_in_locale, R_OK) == 0) { const guint32 mask = (IN_CLOSE_WRITE | IN_MOVE | IN_CREATE | IN_DELETE| IN_DELETE_SELF | IN_MOVE_SELF); int wd; + char *str_wd; wd = inotify_add_watch (inotify_monitor_fd, dir_in_locale, mask); g_free (dir_in_locale); if (wd < 0) { - tracker_log ("Inotify watch on %s has failed", dir); + g_message ("Inotify watch on %s has failed", dir); return FALSE; - } else { - char *str_wd; - - str_wd = g_strdup_printf ("%d", wd); - tracker_exec_proc (db_con, "InsertWatch", 2, dir, str_wd); - g_free (str_wd); - inotify_count++; - tracker_log ("Watching directory %s (total watches = %d)", dir, inotify_count); - return TRUE; } + + str_wd = g_strdup_printf ("%d", wd); + tracker_exec_proc (db_con, "InsertWatch", 2, dir, str_wd); + g_free (str_wd); + inotify_count++; + g_message ("Watching directory %s (total watches = %d)", dir, inotify_count); + return TRUE; } g_free (dir_in_locale); @@ -677,41 +654,30 @@ static gboolean delete_watch (const char *dir, DBConnection *db_con) { - char ***res; - int wd; - gboolean found; + char ***res; + int wd; + char **row; - if (!dir || strlen (dir) == 0 || dir[0] != G_DIR_SEPARATOR) { - return FALSE; - } + g_return_val_if_fail (dir != NULL && dir[0] == G_DIR_SEPARATOR, FALSE); res = tracker_exec_proc (db_con, "GetWatchID", 1, dir); wd = -1; - if (res) { - char **row; - - row = tracker_db_get_row (res, 0); - - if (row && row[0]) { - wd = atoi (row[0]); - found = TRUE; - } else { - found = FALSE; - } - - tracker_db_free_result (res); - - } else { - found = FALSE; + if (!res) { + g_message ("WARNING : watch id not found for uri %s", dir); + return FALSE; } - if (!found) { - tracker_log ("WARNING : watch id not found for uri %s", dir); + row = tracker_db_get_row (res, 0); + + if (!row || !row[0]) { + g_message ("WARNING : watch id not found for uri %s", dir); return FALSE; } + wd = atoi (row[0]); + tracker_exec_proc (db_con, "DeleteWatch", 1, dir); if (wd > -1) { @@ -726,44 +692,42 @@ void tracker_remove_watch_dir (const char *dir, gboolean delete_subdirs, DBConnection *db_con) { - if (!dir || strlen (dir) == 0 || dir[0] != G_DIR_SEPARATOR) { - return; - } + char ***res; + char **row; + int k; + int wd; + + g_return_if_fail (dir != NULL && dir[0] == G_DIR_SEPARATOR); delete_watch (dir, db_con); - if (delete_subdirs) { - char ***res; - int wd; + if (!delete_subdirs) { + return; + } - res = tracker_db_get_sub_watches (db_con, dir); + res = tracker_db_get_sub_watches (db_con, dir); - wd = -1; + wd = -1; - if (res) { - char **row; - int k; + if (!res) { + return; + } - k = 0; + for (k = 0; (row = tracker_db_get_row (res, k)) && row[0]; k++) { - while ((row = tracker_db_get_row (res, k))) { - k++; + wd = atoi (row[0]); - if (row && row[0]) { - wd = atoi (row[0]); - if (wd > -1) { - inotify_rm_watch (inotify_monitor_fd, wd); - inotify_count--; - } - } - } + if (wd < 0) { + continue; + } - tracker_db_free_result (res); + inotify_rm_watch (inotify_monitor_fd, wd); + inotify_count--; + } - tracker_db_delete_sub_watches (db_con, dir); + tracker_db_free_result (res); - } - } + tracker_db_delete_sub_watches (db_con, dir); } Index: tracker-metadata.c =================================================================== RCS file: /cvs/gnome/tracker/src/trackerd/tracker-metadata.c,v retrieving revision 1.9 diff -u -d -r1.9 tracker-metadata.c --- tracker-metadata.c 9 Sep 2006 23:54:08 -0000 1.9 +++ tracker-metadata.c 20 Sep 2006 05:52:05 -0000 @@ -275,13 +275,13 @@ g_free (text_filter_file); if (!argv[1]) { - tracker_log ("******ERROR**** uri could not be converted to locale format"); + g_message ("******ERROR**** uri could not be converted to locale format"); g_free (argv[0]); g_free (argv[2]); return NULL; } - tracker_log ("extracting text for %s using filter %s", argv[1], argv[0]); + g_message ("extracting text for %s using filter %s", argv[1], argv[0]); if (g_spawn_sync (NULL, argv, @@ -358,14 +358,14 @@ argv[4] = NULL; if (!argv[1]) { - tracker_log ("******ERROR**** uri could not be converted to locale format"); + g_message ("******ERROR**** uri could not be converted to locale format"); g_free (argv[0]); g_free (argv[2]); g_free (argv[3]); return NULL; } - tracker_log ("Extracting thumbnail for %s using %s", argv[1], argv[0] ); + g_message ("Extracting thumbnail for %s using %s", argv[1], argv[0] ); if (g_spawn_sync (NULL, argv, @@ -423,7 +423,7 @@ argv[3] = NULL; if (!argv[1] || !argv[2]) { - tracker_log ("******ERROR**** uri or mime could not be converted to locale format"); + g_message ("******ERROR**** uri or mime could not be converted to locale format"); g_free (argv[0]); @@ -488,7 +488,7 @@ utf_value = g_strdup (meta_value); } - tracker_log ("%s = %s", meta_name, utf_value); + g_message ("%s = %s", meta_name, utf_value); g_hash_table_insert (table, g_strdup (meta_name), g_strdup (utf_value)); Index: tracker-rdf-query.c =================================================================== RCS file: /cvs/gnome/tracker/src/trackerd/tracker-rdf-query.c,v retrieving revision 1.13 diff -u -d -r1.13 tracker-rdf-query.c --- tracker-rdf-query.c 16 Sep 2006 16:54:02 -0000 1.13 +++ tracker-rdf-query.c 20 Sep 2006 05:52:05 -0000 @@ -761,9 +761,9 @@ long cvalue; bvalue = tracker_format_date (avalue); - tracker_log (bvalue); + g_message (bvalue); cvalue = tracker_str_to_date (bvalue); - tracker_log ("%d", cvalue); + g_message ("%d", cvalue); value = tracker_long_to_str (cvalue); g_free (bvalue); } else { @@ -1080,7 +1080,7 @@ GError *error, gpointer user_data) { - tracker_log ("Error in rdf query parse: %s", error->message); + g_message ("Error in rdf query parse: %s", error->message); } @@ -1117,7 +1117,7 @@ field_data = add_metadata_field (&data, fields[i], TRUE, FALSE); if (!field_data) { - tracker_log ("RDF Query failed : field %s not found", fields[i]); + g_message ("RDF Query failed : field %s not found", fields[i]); g_slist_foreach (data.fields, (GFunc) free_metadata_field, NULL); g_slist_free (data.fields); g_string_free (data.sql_select, TRUE); Index: tracker-utils.c =================================================================== RCS file: /cvs/gnome/tracker/src/trackerd/tracker-utils.c,v retrieving revision 1.26 diff -u -d -r1.26 tracker-utils.c --- tracker-utils.c 16 Sep 2006 16:54:02 -0000 1.26 +++ tracker-utils.c 20 Sep 2006 05:52:05 -0000 @@ -529,7 +529,7 @@ } if (*timestamp++ != 'T') { - tracker_log ("date validation failed for %s st %c", timestamp, *timestamp); + g_message ("date validation failed for %s st %c", timestamp, *timestamp); return -1; } @@ -716,7 +716,7 @@ void tracker_print_object_allocations () { - tracker_log ("total allocations = %d, total deallocations = %d", info_allocated, info_deallocated); + g_message ("total allocations = %d, total deallocations = %d", info_allocated, info_deallocated); } @@ -725,7 +725,7 @@ { if (!info || !info->uri) { - tracker_log ("************** Warning Invalid Info struct detected *****************"); + g_message ("************** Warning Invalid Info struct detected *****************"); return FALSE; @@ -734,7 +734,7 @@ if ( !g_utf8_validate (info->uri, -1, NULL) || info->action == TRACKER_ACTION_IGNORE) { if (info->action != TRACKER_ACTION_IGNORE) { - tracker_log ("************** Warning UTF8 Validation of FileInfo URI has failed (possible corruption) *****************"); + g_message ("************** Warning UTF8 Validation of FileInfo URI has failed (possible corruption) *****************"); } tracker_free_file_info (info); @@ -926,7 +926,7 @@ } } else { - tracker_log ("******ERROR**** info->uri could not be converted to locale format"); + g_message ("******ERROR**** info->uri could not be converted to locale format"); return NULL; } @@ -1008,7 +1008,7 @@ uri_in_locale = g_filename_from_utf8 (uri, -1, NULL, NULL, NULL); if (!uri_in_locale) { - tracker_log ("******ERROR**** uri could not be converted to locale format"); + g_message ("******ERROR**** uri could not be converted to locale format"); return FALSE; } @@ -1061,7 +1061,7 @@ uri_in_locale = g_filename_from_utf8 (uri, -1, NULL, NULL, NULL); if (!uri_in_locale) { - tracker_log ("******ERROR**** uri could not be converted to locale format"); + g_message ("******ERROR**** uri could not be converted to locale format"); return FALSE; } @@ -1088,7 +1088,7 @@ uri_in_locale = g_filename_from_utf8 (uri, -1, NULL, NULL, NULL); if (!uri_in_locale) { - tracker_log ("******ERROR**** uri could not be converted to locale format"); + g_message ("******ERROR**** uri could not be converted to locale format"); return FALSE; } @@ -1216,66 +1216,13 @@ return S_ISDIR (finfo.st_mode); } else { - tracker_log ("******ERROR**** dir could not be converted to locale format"); + g_message ("******ERROR**** dir could not be converted to locale format"); return FALSE; } } -void -tracker_log (const char* fmt, ...) -{ - FILE *fd; - time_t now; - char buffer1[64], buffer2[20]; - char *output; - char *msg; - va_list args; - struct tm *loctime; - GTimeVal start; - - va_start (args, fmt); - msg = g_strdup_vprintf (fmt, args); - va_end (args); - - if (msg) { - g_print ("%s\n", msg); - } - - /* ensure file logging is thread safe */ - g_mutex_lock (tracker->log_access_mutex); - - fd = g_fopen (tracker->log_file, "a"); - - if (!fd) { - g_mutex_unlock (tracker->log_access_mutex); - g_warning ("could not open %s", tracker->log_file); - g_free (msg); - return; - } - - g_get_current_time (&start); - - now = time ((time_t *) NULL); - - loctime = localtime (&now); - - strftime (buffer1, 64, "%d %b %Y, %H:%M:%S:", loctime); - - g_sprintf (buffer2, "%ld", start.tv_usec / 1000); - - output = g_strconcat (buffer1, buffer2, " - ", msg, NULL); - g_free (msg); - - g_fprintf (fd, "%s\n", output); - g_free (output); - - fclose (fd); - - g_mutex_unlock (tracker->log_access_mutex); -} - static int has_prefix (const char *str1, const char *str2) @@ -1306,7 +1253,7 @@ dir_in_locale = g_filename_from_utf8 (dir, -1, NULL, NULL, NULL); if (!dir_in_locale) { - tracker_log ("******ERROR**** dir could not be converted to utf8 format"); + g_message ("******ERROR**** dir could not be converted to utf8 format"); g_free (dir_in_locale); return NULL; } @@ -1440,7 +1387,7 @@ static void display_list_values (const char *uri) { - tracker_log ("setting no watch directory %s", uri); + g_message ("setting no watch directory %s", uri); } @@ -1628,7 +1575,7 @@ g_mutex_lock (tracker->poll_access_mutex); tracker->poll_list = g_slist_prepend (tracker->poll_list, g_strdup (dir)); g_mutex_unlock (tracker->poll_access_mutex); - tracker_log ("adding %s for polling (poll count is %d)", dir, g_slist_length (tracker->poll_list)); + g_message ("adding %s for polling (poll count is %d)", dir, g_slist_length (tracker->poll_list)); } Index: tracker-utils.h =================================================================== RCS file: /cvs/gnome/tracker/src/trackerd/tracker-utils.h,v retrieving revision 1.14 diff -u -d -r1.14 tracker-utils.h --- tracker-utils.h 13 Sep 2006 17:11:54 -0000 1.14 +++ tracker-utils.h 20 Sep 2006 05:52:05 -0000 @@ -218,8 +218,6 @@ char * tracker_get_mime_type (const char *uri); -void tracker_log (const char *fmt, ...); - GSList * tracker_get_files (const char *dir, gboolean dir_only); gboolean tracker_file_is_valid (const char *uri);