Merge lp:~dobey/libubuntuone/rescan-library into lp:libubuntuone

Proposed by dobey
Status: Merged
Approved by: dobey
Approved revision: 131
Merged at revision: 131
Proposed branch: lp:~dobey/libubuntuone/rescan-library
Merge into: lp:libubuntuone
Diff against target: 80 lines (+63/-0)
1 file modified
libubuntuone/u1-music-store.c (+63/-0)
To merge this branch: bzr merge lp:~dobey/libubuntuone/rescan-library
Reviewer Review Type Date Requested Status
Manuel de la Peña (community) Approve
Eric Casteleijn (community) Approve
Review via email: mp+56650@code.launchpad.net

Commit message

Rescan the Purchased Music folder asynchronously on startup

Description of the change

To test:

./autogen.sh
make U1_JAVASCRIPT_DIR=`pwd`/data

Copy another mp3 into ~/.ubuntuone/Purchased from Ubuntu One/

LD_PRELOAD=`pwd`/libubuntuone/.libs/libubuntuone-1.0.so.1.0.0 banshee

Switch to the Ubuntu One Music Store source. The song should then appear in the library. The store widget does not get initialized until switching to the source, so a patch to banshee will also be required to make this happen on startup. I have that patch as well and will file it upstream with a requirement on new version of libubuntuone once this branch is landed and I make a release.

To post a comment you must log in.
Revision history for this message
Eric Casteleijn (thisfred) :
review: Approve
Revision history for this message
Manuel de la Peña (mandel) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libubuntuone/u1-music-store.c'
2--- libubuntuone/u1-music-store.c 2011-04-01 17:19:03 +0000
3+++ libubuntuone/u1-music-store.c 2011-04-06 20:50:48 +0000
4@@ -1160,6 +1160,67 @@
5 }
6
7 static void
8+_u1_purchased_enumerate (GObject *source, GAsyncResult *result,
9+ gpointer user_data)
10+{
11+ U1MusicStore *music_store = U1_MUSIC_STORE (user_data);
12+ GFile *dir = G_FILE (source);
13+ GFileEnumerator *files;
14+ GFileInfo *info;
15+ GError *error = NULL;
16+
17+ files = g_file_enumerate_children_finish (dir, result, &error);
18+
19+ if (error != NULL) {
20+ g_warning ("Error rescanning Purchased Music: %s", error->message);
21+ g_error_free (error);
22+ return;
23+ }
24+
25+ while ((info = g_file_enumerator_next_file (files, NULL, NULL)) != NULL) {
26+ gchar *path;
27+
28+ path = g_build_filename (g_file_get_path (dir),
29+ g_file_info_get_name (info),
30+ NULL);
31+ if (g_file_test (path, G_FILE_TEST_IS_DIR)) {
32+ GFile *subdir = g_file_new_for_path (path);
33+ g_file_enumerate_children_async (subdir,
34+ G_FILE_ATTRIBUTE_STANDARD_NAME,
35+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
36+ G_PRIORITY_DEFAULT, NULL,
37+ (GAsyncReadyCallback) _u1_purchased_enumerate,
38+ music_store);
39+ } else if (g_file_test (path, G_FILE_TEST_IS_REGULAR)) {
40+ g_signal_emit (music_store,
41+ u1_music_store_signals[DOWNLOAD_FINISHED_SIGNAL], 0,
42+ (const gchar *) path);
43+ }
44+
45+ g_free (path);
46+ g_object_unref (info);
47+ }
48+ g_file_enumerator_close (files, NULL, NULL);
49+ g_object_unref (dir);
50+}
51+
52+static void
53+_u1_music_store_rescan_purchased_folder (U1MusicStore *music_store)
54+{
55+ GFile *dir;
56+ const gchar *path;
57+
58+ path = u1_music_store_get_library_location (music_store);
59+ dir = g_file_new_for_path (path);
60+ g_file_enumerate_children_async (dir,
61+ G_FILE_ATTRIBUTE_STANDARD_NAME,
62+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
63+ G_PRIORITY_DEFAULT, NULL,
64+ (GAsyncReadyCallback) _u1_purchased_enumerate,
65+ music_store);
66+}
67+
68+static void
69 u1_music_store_init (U1MusicStore *music_store)
70 {
71 gchar *new_user_agent;
72@@ -1293,6 +1354,8 @@
73 gtk_box_pack_start (GTK_BOX (music_store), music_store->priv->alertbar, FALSE, FALSE, 6);
74 gtk_box_pack_start (GTK_BOX (music_store), music_store->priv->scroll, TRUE, TRUE, 0);
75 gtk_box_pack_end (GTK_BOX (music_store), music_store->priv->progress, FALSE, FALSE, 0);
76+
77+ _u1_music_store_rescan_purchased_folder (music_store);
78 }
79
80 /**

Subscribers

People subscribed via source and target branches