[Weekly Report] Week 4: Rhythmbox iPod/MTP Syncing



This last week I have been working on the Syncing function for the iPod. I am using the iPod plugin as a way to prototype the syncing function before moving the appropriate code up to the RBMediaPlayerSource, and into the MTP plugin.

The big victory for me last week was to get the GKeyFile saving data for the different iPods. In order to associate the preferences (auto-sync, sync podcasts?, what to sync, etc...) with the device, the plugin saves a GKeyFile ipod-prefs.conf. The file is not created/loaded until it is needed. In the file there is a group for each iPod, which stores all it's properties, and a list of playlists selected for syncing. In order to parse this file and pass it nicely between the plugin and each RBiPodSource, a new GObject was needed, RBiPodPrefs. When a new RBiPodSource is being constructed the plugin will pass it a pointer to the plugin's keyfile. The RBiPodPrefs is created in RBiPodSourcePrivate->prefs, and if/when the prefs are accessed RBiPodPrefs loads/saves the file as needed. There was a bit of debugging to do with this, (functions which return errors, calling other sub-functions which return errors), and so I was learning about GError objects. To have a unique device identifier, I got the rb_ipod_helpers_get_serial() function working, so now the identifier in the GKeyFile is the serial number for the device. Last week, I also started on the hashing stuff, for comparison between the itinerary (what is to be synced) and the ipod database. I created two functions for the hash table (a hashing one, and a comparison one). The hashing one does a g_str_hash ( Title + Artist + Duration + Album ), where the plus signs are appending. The plan for comparison between the databases is to have two GHashTables, one populated from the itinerary, and one from the iPod, that we can compare between and figure out what needs addition and what needs removal.

A few entries from my work log:
   : wrote hashing and equality functions.
- The equality function simply calls a hash on both, then compares that - The hashing function has a comment which could be added to increase specificity for podcasts if needed. : Added rb-ipod-prefs.h and rb-ipod-prefs.c, to help passing preferences between the rb-ipod-source and the rb-ipod-plugin : Worked on rb-ipod-prefs. got it being used by RBiPodSource and RBIpodPlugin, and building.
   : Fixed rb-ipod-prefs
       - Ignores it if it can't find the file.
       - File will be created at first save.
: Fixed the rb_ipod_helpers_get_serial() function, now queries Hal for parent_udi->storage.serial

This coming week I will be continuing work on the syncing mechanisms, focusing on populating the GHashTables. I have already got the ipod_sync_hash populated from ipod_db->entry_map. However, I am a bit stuck on how to populate the itinerary_sync_hash. It will get a list of playlist names from the GKeyFile, and has a pointer to the RhythmDB for the library (passed via the 'shell' object). However, I am not sure how to get from the playlist names, to a list of the entries in that playlist. The current method is something similar to:
#    // Get all the names of the playlists
# rb_playlist_manager_get_playlist_names ((RBPlaylistManager *) rb_shell_get_playlist_manager (shell),
#                        &playlists,
#                        NULL);
#    // for each entry in the GKeyFile
# for ( iter = (const gchar **) rb_ipod_prefs_get_entries( ipod_priv->prefs );
#          *iter != NULL;
#          iter++ )
#    {
#        // get playlist with matching name.
# for (playlist_iter = (const gchar **) playlists; playlist_iter != NULL; playlist_iter++ ) {
#            if ( playlist_iter == iter  ) {
# // Get it's RBPlaylistSourcePrivate so we can get at it's entries. # pl_priv = PLAYLIST_SOURCE_GET_PRIVATE ((RBPlaylistSource *) _get_playlist_by_name ((RBPlaylistManager *) rb_shell_get_playlist_manager (shell), playlist_iter)); # // Insert the entres for this playlist into the itinerary_sync_hash # g_hash_table_foreach ( pl_priv->entries, rb_ipod_helpers_hash_table_insert, itinerary_sync_hash );
#                break;
#            }
#        }
#    }

Obviously, the above will not quite work. If anyone has any advice on how to do this in a better way I would *really* appreciate it.

Thanks,
Paul


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