tracker r3185 - in trunk: . src/libtracker-common src/tracker-extract src/tracker-indexer tests/tracker-extract
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r3185 - in trunk: . src/libtracker-common src/tracker-extract src/tracker-indexer tests/tracker-extract
- Date: Tue, 7 Apr 2009 12:39:17 +0000 (UTC)
Author: mr
Date: Tue Apr 7 12:39:17 2009
New Revision: 3185
URL: http://svn.gnome.org/viewvc/tracker?rev=3185&view=rev
Log:
* src/libtracker-common/tracker-thumbnailer.h:
* src/libtracker-common/tracker-albumart.h: Added preprocessor
checks for __LIBTRACKER_COMMON_INSIDE__ which were missing.
* src/libtracker-common/tracker-albumart.[ch]:
* src/tracker-extract/tracker-extract-mp3.c: Fixed coding style
issues.
* src/libtracker-common/tracker-albumart.[ch]:
* src/tracker-extract/tracker-extract-albumart.c:
* src/tracker-extract/tracker-main.[ch]: Only create one
TrackerHal object during the life time of tracker-extract instead
of for EVERY file which has album art (which is quite a lot). This
seems to be showing an increase of 2x the speed now for
tracker-extract.
* src/tracker-indexer/tracker-main.c: (main): Added print
statement like we have in the daemon so we know when the process
is finished and returning to the cmd line.
* tests/tracker-extract/tracker-extract-test-utils.c:
(tracker_test_extract_file_access): Added tracker_main_get_hal()
fixes to ensure the tests build.
Modified:
trunk/ChangeLog
trunk/src/libtracker-common/tracker-albumart.c
trunk/src/libtracker-common/tracker-albumart.h
trunk/src/libtracker-common/tracker-thumbnailer.h
trunk/src/tracker-extract/tracker-extract-albumart.c
trunk/src/tracker-extract/tracker-extract-mp3.c
trunk/src/tracker-extract/tracker-extract.c
trunk/src/tracker-extract/tracker-main.c
trunk/src/tracker-extract/tracker-main.h
trunk/src/tracker-indexer/tracker-main.c
trunk/tests/tracker-extract/tracker-extract-test-utils.c
Modified: trunk/src/libtracker-common/tracker-albumart.c
==============================================================================
--- trunk/src/libtracker-common/tracker-albumart.c (original)
+++ trunk/src/libtracker-common/tracker-albumart.c Tue Apr 7 12:39:17 2009
@@ -55,8 +55,9 @@
#define THUMBNAILER_INTERFACE "org.freedesktop.thumbnailer.Generic"
typedef struct {
- gchar *art_path;
- gchar *local_uri;
+ TrackerHal *hal;
+ gchar *art_path;
+ gchar *local_uri;
} GetFileInfo;
static gboolean no_more_requesting = FALSE;
@@ -66,18 +67,18 @@
const guchar *data,
gsize length)
{
- GChecksum *checksum;
- gchar *retval;
-
- checksum = g_checksum_new (checksum_type);
- if (!checksum)
- return NULL;
-
- g_checksum_update (checksum, data, length);
- retval = g_strdup (g_checksum_get_string (checksum));
- g_checksum_free (checksum);
-
- return retval;
+ GChecksum *checksum;
+ gchar *retval;
+
+ checksum = g_checksum_new (checksum_type);
+ if (!checksum)
+ return NULL;
+
+ g_checksum_update (checksum, data, length);
+ retval = g_strdup (g_checksum_get_string (checksum));
+ g_checksum_free (checksum);
+
+ return retval;
}
#ifndef HAVE_STRCASESTR
@@ -174,8 +175,6 @@
return g_file_make_directory (file, cancellable, error);
}
-
-
static gchar*
strip_characters (const gchar *original)
{
@@ -185,9 +184,7 @@
guint i = 0, y = 0;
while (i < osize) {
-
/* Remove (anything) */
-
if (original[i] == '(') {
gchar *loc = strchr (original+i, ')');
if (loc) {
@@ -197,7 +194,6 @@
}
/* Remove [anything] */
-
if (original[i] == '[') {
gchar *loc = strchr (original+i, ']');
if (loc) {
@@ -207,7 +203,6 @@
}
/* Remove {anything} */
-
if (original[i] == '{') {
gchar *loc = strchr (original+i, '}');
if (loc) {
@@ -217,7 +212,6 @@
}
/* Remove <anything> */
-
if (original[i] == '<') {
gchar *loc = strchr (original+i, '>');
if (loc) {
@@ -227,7 +221,6 @@
}
/* Remove double whitespaces */
-
if ((y > 0) &&
(original[i] == ' ' || original[i] == '\t') &&
(retval[y-1] == ' ' || retval[y-1] == '\t')) {
@@ -236,7 +229,6 @@
}
/* Remove strange characters */
-
if (!strchr (foo, original[i])) {
retval[y] = original[i]!='\t'?original[i]:' ';
y++;
@@ -250,31 +242,25 @@
return retval;
}
-
void
-tracker_albumart_copy_to_local (const gchar *filename, const gchar *local_uri)
+tracker_albumart_copy_to_local (TrackerHal *hal,
+ const gchar *filename,
+ const gchar *local_uri)
{
-#ifdef HAVE_HAL
- TrackerHal *hal;
-#endif
GList *removable_roots, *l;
gboolean on_removable_device = FALSE;
guint flen;
- if (!filename)
- return;
-
- if (!local_uri)
- return;
+ g_return_if_fail (filename != NULL);
+ g_return_if_fail (local_uri != NULL);
flen = strlen (filename);
/* Determining if we are on a removable device */
-
#ifdef HAVE_HAL
- hal = tracker_hal_new ();
+ g_return_if_fail (hal != NULL);
+
removable_roots = tracker_hal_get_removable_device_roots (hal);
- g_object_unref (hal);
#else
removable_roots = g_list_append (removable_roots, "/media");
removable_roots = g_list_append (removable_roots, "/mnt");
@@ -344,32 +330,31 @@
gchar *album = NULL;
/* Copy from local album art (.mediaartlocal) to spec */
-
if (local_uri) {
- GFile *local_file;
-
- local_file = g_file_new_for_uri (local_uri);
-
- if (g_file_query_exists (local_file, NULL)) {
-
- tracker_albumart_get_path (artist, album,
- "album", NULL,
- &target, NULL);
-
- file = g_file_new_for_path (target);
-
- g_file_copy_async (local_file, file, 0, 0,
- NULL, NULL, NULL, NULL, NULL);
-
- g_object_unref (file);
+ GFile *local_file;
+
+ local_file = g_file_new_for_uri (local_uri);
+
+ if (g_file_query_exists (local_file, NULL)) {
+ tracker_albumart_get_path (artist, album,
+ "album", NULL,
+ &target, NULL);
+
+ file = g_file_new_for_path (target);
+
+ g_file_copy_async (local_file, file, 0, 0,
+ NULL, NULL, NULL, NULL, NULL);
+
+ g_object_unref (file);
+ g_object_unref (local_file);
+
+ *copied = TRUE;
+ g_free (target);
+
+ return TRUE;
+ }
+
g_object_unref (local_file);
-
- *copied = TRUE;
- g_free (target);
-
- return TRUE;
- }
- g_object_unref (local_file);
}
*copied = FALSE;
@@ -401,10 +386,13 @@
tracks = -1;
}
- if (artist_)
+ if (artist_) {
artist = strip_characters (artist_);
- if (album_)
+ }
+
+ if (album_) {
album = strip_characters (album_);
+ }
/* If amount of files and amount of tracks in the album somewhat match */
@@ -413,7 +401,6 @@
gchar *found = NULL;
/* Try to find cover art in the directory */
-
for (name = g_dir_read_name (dir); name; name = g_dir_read_name (dir)) {
if ((artist && strcasestr (name, artist)) ||
(album && strcasestr (name, album)) ||
@@ -484,8 +471,9 @@
#endif /* HAVE_GDKPIXBUF */
}
- if (retval)
+ if (retval) {
break;
+ }
}
}
@@ -529,7 +517,6 @@
return albart_proxy;
}
-
static void
tracker_albumart_queue_cb (DBusGProxy *proxy,
DBusGProxyCall *call,
@@ -561,12 +548,18 @@
tracker_thumbnailer_queue_file (uri, "image/jpeg");
g_free (uri);
- tracker_albumart_copy_to_local (info->art_path, info->local_uri);
+ tracker_albumart_copy_to_local (info->hal,
+ info->art_path,
+ info->local_uri);
}
g_free (info->art_path);
g_free (info->local_uri);
+ if (info->hal) {
+ g_object_unref (info->hal);
+ }
+
g_slice_free (GetFileInfo, info);
}
@@ -598,15 +591,17 @@
return;
}
- if (!a)
+ if (!a) {
f_a = g_strdup (" ");
- else
+ } else {
f_a = strip_characters (a);
+ }
- if (!b)
+ if (!b) {
f_b = g_strdup (" ");
- else
- f_b = strip_characters (b);
+ } else {
+ f_b = strip_characters (b);
+ }
down1 = g_utf8_strdown (f_a, -1);
down2 = g_utf8_strdown (f_b, -1);
@@ -626,7 +621,10 @@
g_free (down1);
g_free (down2);
- art_filename = g_strdup_printf ("%s-%s-%s.jpeg", prefix?prefix:"album", str1, str2);
+ art_filename = g_strdup_printf ("%s-%s-%s.jpeg",
+ prefix ? prefix : "album",
+ str1,
+ str2);
*path = g_build_filename (dir, art_filename, NULL);
@@ -634,10 +632,11 @@
gchar *local_dir;
GFile *file, *parent;
- if (strchr (uri, ':'))
+ if (strchr (uri, ':')) {
file = g_file_new_for_uri (uri);
- else
- file = g_file_new_for_path (uri);
+ } else {
+ file = g_file_new_for_path (uri);
+ }
parent = g_file_get_parent (file);
local_dir = g_file_get_uri (parent);
@@ -657,18 +656,28 @@
}
void
-tracker_albumart_request_download (const gchar *album,
+tracker_albumart_request_download (TrackerHal *hal,
+ const gchar *album,
const gchar *artist,
const gchar *local_uri,
const gchar *art_path)
{
GetFileInfo *info;
- if (no_more_requesting)
+ g_return_if_fail (hal != NULL);
+
+ if (no_more_requesting) {
return;
+ }
info = g_slice_new (GetFileInfo);
+#ifdef HAVE_HAL
+ info->hal = g_object_ref (hal);
+#else
+ info->hal = NULL;
+#endif
+
info->local_uri = g_strdup (local_uri);
info->art_path = g_strdup (art_path);
Modified: trunk/src/libtracker-common/tracker-albumart.h
==============================================================================
--- trunk/src/libtracker-common/tracker-albumart.h (original)
+++ trunk/src/libtracker-common/tracker-albumart.h Tue Apr 7 12:39:17 2009
@@ -26,13 +26,20 @@
G_BEGIN_DECLS
+#if !defined (__LIBTRACKER_COMMON_INSIDE__) && !defined (TRACKER_COMPILATION)
+#error "only <libtracker-common/tracker-common.h> must be included directly."
+#endif
+
+#include "tracker-hal.h"
+
gboolean tracker_albumart_heuristic (const gchar *artist_,
const gchar *album_,
const gchar *tracks_str,
const gchar *filename,
const gchar *local_uri,
gboolean *copied);
-void tracker_albumart_copy_to_local (const gchar *filename,
+void tracker_albumart_copy_to_local (TrackerHal *hal,
+ const gchar *filename,
const gchar *local_uri);
void tracker_albumart_get_path (const gchar *a,
const gchar *b,
@@ -40,7 +47,8 @@
const gchar *uri,
gchar **path,
gchar **local);
-void tracker_albumart_request_download (const gchar *album,
+void tracker_albumart_request_download (TrackerHal *hal,
+ const gchar *album,
const gchar *artist,
const gchar *local_uri,
const gchar *art_path);
Modified: trunk/src/libtracker-common/tracker-thumbnailer.h
==============================================================================
--- trunk/src/libtracker-common/tracker-thumbnailer.h (original)
+++ trunk/src/libtracker-common/tracker-thumbnailer.h Tue Apr 7 12:39:17 2009
@@ -26,6 +26,10 @@
G_BEGIN_DECLS
+#if !defined (__LIBTRACKER_COMMON_INSIDE__) && !defined (TRACKER_COMPILATION)
+#error "only <libtracker-common/tracker-common.h> must be included directly."
+#endif
+
void tracker_thumbnailer_init (TrackerConfig *config);
void tracker_thumbnailer_shutdown (void);
void tracker_thumbnailer_queue_file (const gchar *path,
Modified: trunk/src/tracker-extract/tracker-extract-albumart.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract-albumart.c (original)
+++ trunk/src/tracker-extract/tracker-extract-albumart.c Tue Apr 7 12:39:17 2009
@@ -40,6 +40,7 @@
#include <libtracker-common/tracker-common.h>
#include <libtracker-common/tracker-thumbnailer.h>
+#include "tracker-main.h"
#include "tracker-extract-albumart.h"
#ifdef HAVE_GDKPIXBUF
@@ -163,7 +164,8 @@
/* If the heuristic failed, we request the download
* of the media-art to the media-art downloaders */
lcopied = TRUE;
- tracker_albumart_request_download (artist,
+ tracker_albumart_request_download (tracker_main_get_hal (),
+ artist,
album,
local_uri,
art_path);
@@ -189,7 +191,9 @@
if (local_uri && !g_file_test (local_uri, G_FILE_TEST_EXISTS)) {
if (g_file_test (art_path, G_FILE_TEST_EXISTS))
- tracker_albumart_copy_to_local (art_path, local_uri);
+ tracker_albumart_copy_to_local (tracker_main_get_hal (),
+ art_path,
+ local_uri);
}
g_free (art_path);
Modified: trunk/src/tracker-extract/tracker-extract-mp3.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract-mp3.c (original)
+++ trunk/src/tracker-extract/tracker-extract-mp3.c Tue Apr 7 12:39:17 2009
@@ -286,13 +286,14 @@
/* Convert from UCS-2 to UTF-8 checking the BOM.*/
static gchar *
-ucs2_to_utf8(const gchar *data, guint len) {
- gchar *encoding = NULL;
- guint16 c;
- gboolean be;
- gchar *utf8 = NULL;
+ucs2_to_utf8 (const gchar *data, guint len)
+{
+ gchar *encoding = NULL;
+ guint16 c;
+ gboolean be;
+ gchar *utf8 = NULL;
- memcpy(&c, data, 2);
+ memcpy (&c, data, 2);
switch (c) {
case 0xfeff:
@@ -308,7 +309,7 @@
break;
}
- utf8 = g_convert(data, len, "UTF-8", encoding, NULL, NULL, NULL);
+ utf8 = g_convert (data, len, "UTF-8", encoding, NULL, NULL, NULL);
return utf8;
}
@@ -323,15 +324,15 @@
gchar *result = NULL;
if (!regex1)
- regex1 = g_regex_new("\\(([0-9]+)\\)", 0, 0, NULL);
+ regex1 = g_regex_new ("\\(([0-9]+)\\)", 0, 0, NULL);
if (!regex2)
- regex2 = g_regex_new("([0-9]+)\\z", 0, 0, NULL);
+ regex2 = g_regex_new ("([0-9]+)\\z", 0, 0, NULL);
- if (g_regex_match(regex1, str, 0, &info)) {
- result = g_match_info_fetch(info, 1);
+ if (g_regex_match (regex1, str, 0, &info)) {
+ result = g_match_info_fetch (info, 1);
if (result) {
- *genre = atoi(result);
+ *genre = atoi (result);
g_free (result);
g_match_info_free (info);
return TRUE;
@@ -340,10 +341,10 @@
g_match_info_free (info);
- if (g_regex_match(regex2, str, 0, &info)) {
- result = g_match_info_fetch(info, 1);
+ if (g_regex_match (regex2, str, 0, &info)) {
+ result = g_match_info_fetch (info, 1);
if (result) {
- *genre = atoi(result);
+ *genre = atoi (result);
g_free (result);
g_match_info_free (info);
return TRUE;
@@ -367,13 +368,13 @@
*destination = g_malloc0 (size);
dest = *destination;
- new_size = size;
+ new_size = size;
while (offset < size) {
*dest = source[offset];
- if ( (source[offset] == 0xFF) &&
- (source[offset+1] == 0x00) ) {
+ if ((source[offset] == 0xFF) &&
+ (source[offset+1] == 0x00)) {
offset++;
new_size--;
}
@@ -518,7 +519,7 @@
break;
}
- switch (header&mpeg_layer_mask) {
+ switch (header & mpeg_layer_mask) {
case 0x400:
layer_ver = LAYER_2;
padsize = 1;
@@ -555,7 +556,7 @@
g_strdup ("Audio:Channels"),
g_strdup ("1"));
} else {
- ch=2; /*stereo non stereo select*/
+ ch = 2; /* stereo non stereo select */
g_hash_table_insert (metadata,
g_strdup ("Audio:Channels"),
g_strdup ("2"));
@@ -604,7 +605,7 @@
memcpy(&header, &data[pos], sizeof (header));
} while ((header & sync_mask) == sync_mask);
- if (frames<2) { /* At least 2 frames to check the right position */
+ if (frames < 2) { /* At least 2 frames to check the right position */
/* No valid frames */
return FALSE;
}
@@ -643,15 +644,15 @@
do {
/* Seek for frame start */
- if (pos + sizeof(header) > size) {
+ if (pos + sizeof (header) > size) {
return;
}
memcpy (&header, &data[pos], sizeof (header));
- if ((header&sync_mask) == sync_mask) {
+ if ((header & sync_mask) == sync_mask) {
/* Found header sync */
- if (mp3_parse_header (data,size,pos,metadata)) {
+ if (mp3_parse_header (data, size, pos, metadata)) {
return;
}
}
@@ -661,7 +662,6 @@
} while (counter < MAX_MP3_SCAN_DEEP);
}
-
static void
get_id3v24_tags (const gchar *data,
size_t size,
@@ -712,8 +712,8 @@
break;
}
- flags = ( ((unsigned char)(data[pos + 8]) << 8) +
- ((unsigned char)(data[pos + 9]) ) );
+ flags = (((unsigned char) (data[pos + 8]) << 8) +
+ ((unsigned char) (data[pos + 9])));
if (((flags & 0x80) > 0) ||
((flags & 0x40) > 0)) {
pos += 10 + csize;
@@ -738,25 +738,25 @@
switch (data[pos + 10]) {
case 0x00:
- word = g_convert(&data[pos+11],
- csize-1,
- "UTF-8",
- "ISO-8859-1",
- NULL, NULL, NULL);
+ word = g_convert (&data[pos+11],
+ csize-1,
+ "UTF-8",
+ "ISO-8859-1",
+ NULL, NULL, NULL);
break;
case 0x01 :
- word = g_convert(&data[pos+11],
- csize-1,
- "UTF-8",
- "UTF-16",
- NULL, NULL, NULL);
+ word = g_convert (&data[pos+11],
+ csize-1,
+ "UTF-8",
+ "UTF-16",
+ NULL, NULL, NULL);
break;
case 0x02 :
- word = g_convert(&data[pos+11],
- csize-1,
- "UTF-8",
- "UTF-16BE",
- NULL, NULL, NULL);
+ word = g_convert (&data[pos+11],
+ csize-1,
+ "UTF-8",
+ "UTF-16BE",
+ NULL, NULL, NULL);
break;
case 0x03 :
word = strndup (&data[pos+11], csize-1);
@@ -767,11 +767,11 @@
* try to convert from
* iso-8859-1
*/
- word = g_convert(&data[pos+11],
- csize-1,
- "UTF-8",
- "ISO-8859-1",
- NULL, NULL, NULL);
+ word = g_convert (&data[pos+11],
+ csize-1,
+ "UTF-8",
+ "ISO-8859-1",
+ NULL, NULL, NULL);
break;
}
@@ -831,25 +831,25 @@
switch (text_encode) {
case 0x00:
- word = g_convert(text,
- csize-offset,
- "UTF-8",
- "ISO-8859-1",
- NULL, NULL, NULL);
+ word = g_convert (text,
+ csize-offset,
+ "UTF-8",
+ "ISO-8859-1",
+ NULL, NULL, NULL);
break;
case 0x01 :
- word = g_convert(text,
- csize-offset,
- "UTF-8",
- "UTF-16",
- NULL, NULL, NULL);
+ word = g_convert (text,
+ csize-offset,
+ "UTF-8",
+ "UTF-16",
+ NULL, NULL, NULL);
break;
case 0x02 :
- word = g_convert(text,
- csize-offset,
- "UTF-8",
- "UTF-16BE",
- NULL, NULL, NULL);
+ word = g_convert (text,
+ csize-offset,
+ "UTF-8",
+ "UTF-16BE",
+ NULL, NULL, NULL);
break;
case 0x03 :
word = strndup (text, csize-offset);
@@ -860,11 +860,11 @@
* try to convert from
* iso-8859-1
*/
- word = g_convert(text,
- csize-offset,
- "UTF-8",
- "ISO-8859-1",
- NULL, NULL, NULL);
+ word = g_convert (text,
+ csize-offset,
+ "UTF-8",
+ "ISO-8859-1",
+ NULL, NULL, NULL);
break;
}
@@ -892,9 +892,9 @@
pic_type = data[pos+11+strlen(mime)+1];
desc = &data[pos+11+strlen(mime)+1+1];
- if ((pic_type == 3)||((pic_type == 0)&&(filedata->albumartsize == 0))) {
+ if ((pic_type == 3) || ((pic_type == 0) && (filedata->albumartsize == 0))) {
- offset = pos+11+strlen(mime)+2+strlen(desc)+1;
+ offset = pos + 11 + strlen(mime) + 2 + strlen(desc) + 1;
filedata->albumartdata = g_malloc0 (csize);
memcpy (filedata->albumartdata, &data[offset], csize);
@@ -955,8 +955,8 @@
break;
}
- flags = ( ((unsigned char)(data[pos + 8]) << 8) +
- ((unsigned char)(data[pos + 9])) );
+ flags = (((unsigned char)(data[pos + 8]) << 8) +
+ ((unsigned char)(data[pos + 9])));
if (((flags & 0x80) > 0) || ((flags & 0x40) > 0)) {
pos += 10 + csize;
@@ -981,18 +981,18 @@
switch (data[pos + 10]) {
case 0x00:
- word = g_convert(&data[pos+11],
- csize-1,
- "UTF-8",
- "ISO-8859-1",
- NULL, NULL, NULL);
+ word = g_convert (&data[pos+11],
+ csize-1,
+ "UTF-8",
+ "ISO-8859-1",
+ NULL, NULL, NULL);
break;
case 0x01 :
-/* word = g_convert(&data[pos+11], */
-/* csize-1, */
-/* "UTF-8", */
-/* "UCS-2", */
-/* NULL, NULL, NULL); */
+/* word = g_convert (&data[pos+11], */
+/* csize-1, */
+/* "UTF-8", */
+/* "UCS-2", */
+/* NULL, NULL, NULL); */
word = ucs2_to_utf8 (&data[pos+11],
csize-1);
break;
@@ -1001,18 +1001,18 @@
* try to convert from
* iso-8859-1
*/
- word = g_convert(&data[pos+11],
- csize-1,
- "UTF-8",
- "ISO-8859-1",
- NULL, NULL, NULL);
+ word = g_convert (&data[pos+11],
+ csize-1,
+ "UTF-8",
+ "ISO-8859-1",
+ NULL, NULL, NULL);
break;
}
pos++;
csize--;
- if (word != NULL && strlen(word) > 0) {
+ if (word != NULL && strlen (word) > 0) {
if (strcmp (tmap[i].text, "TRCK") == 0) {
gchar **parts;
@@ -1065,18 +1065,18 @@
switch (text_encode) {
case 0x00:
- word = g_convert(text,
- csize-offset,
- "UTF-8",
- "ISO-8859-1",
- NULL, NULL, NULL);
+ word = g_convert (text,
+ csize-offset,
+ "UTF-8",
+ "ISO-8859-1",
+ NULL, NULL, NULL);
break;
case 0x01 :
-/* word = g_convert(text, */
-/* csize-offset, */
-/* "UTF-8", */
-/* "UCS-2", */
-/* NULL, NULL, NULL); */
+/* word = g_convert (text, */
+/* csize-offset, */
+/* "UTF-8", */
+/* "UCS-2", */
+/* NULL, NULL, NULL); */
word = ucs2_to_utf8 (&data[pos+11],
csize-offset);
break;
@@ -1110,15 +1110,13 @@
const gchar *desc;
guint offset;
-
text_type = data[pos+10];
mime = &data[pos+11];
pic_type = data[pos+11+strlen(mime)+1];
desc = &data[pos+11+strlen(mime)+1+1];
- if ((pic_type == 3)||((pic_type == 0)&&(filedata->albumartsize == 0))) {
-
- offset = pos+11+strlen(mime)+2+strlen(desc)+1;
+ if ((pic_type == 3) || ((pic_type == 0) && (filedata->albumartsize == 0))) {
+ offset = pos + 11 + strlen (mime) + 2 + strlen (desc) + 1;
filedata->albumartdata = g_malloc0 (csize);
memcpy (filedata->albumartdata, &data[offset], csize);
@@ -1194,18 +1192,18 @@
*/
switch (data[pos + 6]) {
case 0x00:
- word = g_convert(&data[pos+7],
- csize-1,
- "UTF-8",
- "ISO-8859-1",
- NULL, NULL, NULL);
+ word = g_convert (&data[pos+7],
+ csize-1,
+ "UTF-8",
+ "ISO-8859-1",
+ NULL, NULL, NULL);
break;
case 0x01 :
-/* word = g_convert(&data[pos+7], */
-/* csize, */
-/* "UTF-8", */
-/* "UCS-2", */
-/* NULL, NULL, NULL); */
+/* word = g_convert (&data[pos+7], */
+/* csize, */
+/* "UTF-8", */
+/* "UCS-2", */
+/* NULL, NULL, NULL); */
word = ucs2_to_utf8 (&data[pos+7],
csize-1);
break;
@@ -1214,18 +1212,18 @@
* try to convert from
* iso-8859-1
*/
- word = g_convert(&data[pos+7],
- csize-1,
- "UTF-8",
- "ISO-8859-1",
- NULL, NULL, NULL);
+ word = g_convert (&data[pos+7],
+ csize-1,
+ "UTF-8",
+ "ISO-8859-1",
+ NULL, NULL, NULL);
break;
}
pos++;
csize--;
- if (word != NULL && strlen(word) > 0) {
+ if (word != NULL && strlen (word) > 0) {
if (strcmp (tmap[i].text, "COM") == 0) {
gchar *s;
@@ -1241,7 +1239,7 @@
word = g_strdup (genre_names[genre]);
}
- if (strcasecmp (word, "unknown")==0) {
+ if (strcasecmp (word, "unknown") == 0) {
break;
}
}
@@ -1265,17 +1263,15 @@
const gchar *desc;
guint offset;
- pic_type = data[pos+6+3+1+3];
- desc = &data[pos+6+3+1+3+1];
-
- if ((pic_type == 3)||((pic_type == 0)&&(filedata->albumartsize == 0))) {
+ pic_type = data[pos + 6 + 3 + 1 + 3];
+ desc = &data[pos + 6 + 3 + 1 + 3 + 1];
- offset = pos+6+3+1+3+1+strlen(desc)+1;
+ if ((pic_type == 3) || ((pic_type == 0) && (filedata->albumartsize == 0))) {
+ offset = pos + 6 + 3 + 1 + 3 + 1 + strlen (desc) + 1;
filedata->albumartdata = g_malloc0 (csize);
memcpy (filedata->albumartdata, &data[offset], csize);
filedata->albumartsize = csize;
-
}
}
Modified: trunk/src/tracker-extract/tracker-extract.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract.c (original)
+++ trunk/src/tracker-extract/tracker-extract.c Tue Apr 7 12:39:17 2009
@@ -302,7 +302,6 @@
g_object_unref (info);
g_object_unref (file);
-
/* Now we have sanity checked everything, actually get the
* data we need from the extractors.
*/
Modified: trunk/src/tracker-extract/tracker-main.c
==============================================================================
--- trunk/src/tracker-extract/tracker-main.c (original)
+++ trunk/src/tracker-extract/tracker-main.c Tue Apr 7 12:39:17 2009
@@ -66,13 +66,14 @@
#define QUIT_TIMEOUT 30 /* 1/2 minutes worth of seconds */
-static GMainLoop *main_loop;
-static guint quit_timeout_id = 0;
-
-static gboolean version;
-static gint verbosity = -1;
-static gchar *filename;
-static gchar *mime_type;
+static GMainLoop *main_loop;
+static guint quit_timeout_id = 0;
+static TrackerHal *hal;
+
+static gboolean version;
+static gint verbosity = -1;
+static gchar *filename;
+static gchar *mime_type;
static GOptionEntry entries[] = {
{ "version", 'V', 0,
@@ -117,6 +118,19 @@
NULL);
}
+TrackerHal *
+tracker_main_get_hal (void)
+{
+ if (!hal) {
+#ifdef HAVE_HAL
+ hal = tracker_hal_new ();
+#else
+ hal = NULL;
+#endif
+ }
+
+ return hal;
+}
static void
initialize_priority (void)
@@ -328,11 +342,17 @@
g_main_loop_run (main_loop);
g_main_loop_unref (main_loop);
+ g_message ("Shutdown started");
+
/* Shutdown subsystems */
tracker_dbus_shutdown ();
tracker_thumbnailer_shutdown ();
tracker_log_shutdown ();
+ if (hal) {
+ g_object_unref (hal);
+ }
+
g_free (log_filename);
g_object_unref (config);
Modified: trunk/src/tracker-extract/tracker-main.h
==============================================================================
--- trunk/src/tracker-extract/tracker-main.h (original)
+++ trunk/src/tracker-extract/tracker-main.h Tue Apr 7 12:39:17 2009
@@ -24,6 +24,8 @@
#include <glib.h>
+#include <libtracker-common/tracker-hal.h>
+
#include "tracker-escape.h"
G_BEGIN_DECLS
@@ -42,6 +44,12 @@
/* This is defined in each extract */
TrackerExtractData *tracker_get_extract_data (void);
+/* Some modules need to use the albumart API which requires HAL. To
+ * avoid creating new HAL objects constantly, we initialize it once
+ * and it is available using this API.
+ */
+TrackerHal * tracker_main_get_hal (void);
+
/* This is used to not shutdown after the default of 30 seconds if we
* get more work to do.
*/
Modified: trunk/src/tracker-indexer/tracker-main.c
==============================================================================
--- trunk/src/tracker-indexer/tracker-main.c (original)
+++ trunk/src/tracker-indexer/tracker-main.c Tue Apr 7 12:39:17 2009
@@ -438,5 +438,7 @@
tracker_module_config_shutdown ();
tracker_log_shutdown ();
+ g_print ("\nOK\n\n");
+
return EXIT_SUCCESS;
}
Modified: trunk/tests/tracker-extract/tracker-extract-test-utils.c
==============================================================================
--- trunk/tests/tracker-extract/tracker-extract-test-utils.c (original)
+++ trunk/tests/tracker-extract/tracker-extract-test-utils.c Tue Apr 7 12:39:17 2009
@@ -326,3 +326,12 @@
g_hash_table_destroy (metadata);
}
}
+
+/* This is added because tracker-main.c includes this file and so
+ * should we otherwise it is missing when we try to build the tests.
+ */
+TrackerHal *
+tracker_main_get_hal (void)
+{
+ return NULL;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]