Revision: 2355
http://gtkpod.svn.sourceforge.net/gtkpod/?rev=2355&view=rev
Author: teuf
Date: 2009-05-02 20:55:46 +0000 (Sat, 02 May 2009)
Log Message:
-----------
Mount ipod to collect more ipod properties
Modified Paths:
--------------
libgpod/trunk/ChangeLog
libgpod/trunk/tools/hal-callout.c
Modified: libgpod/trunk/ChangeLog
===================================================================
--- libgpod/trunk/ChangeLog 2009-05-02 20:55:29 UTC (rev 2354)
+++ libgpod/trunk/ChangeLog 2009-05-02 20:55:46 UTC (rev 2355)
@@ -1,5 +1,10 @@
2009-05-02 Christophe Fergeau <[email protected]>
+ * tools/hal-callout.c: mount ipod to collect more ipod
+ properties
+
+2009-05-02 Christophe Fergeau <[email protected]>
+
* tools/hal-callout.c: set ipod.images.formats in hal
2009-05-02 Christophe Fergeau <[email protected]>
Modified: libgpod/trunk/tools/hal-callout.c
===================================================================
--- libgpod/trunk/tools/hal-callout.c 2009-05-02 20:55:29 UTC (rev 2354)
+++ libgpod/trunk/tools/hal-callout.c 2009-05-02 20:55:46 UTC (rev 2355)
@@ -512,10 +512,10 @@
formats, CHAPTER);
}
-static gboolean hal_ipod_set_properties (const SysInfoIpodProperties *props)
+static gboolean hal_ipod_set_properties (LibHalContext *ctx,
+ const char *udi,
+ const SysInfoIpodProperties *props)
{
- LibHalContext *ctx;
- const char *udi;
const char *serial_number;
const char *firmware_version;
char *icon_name;
@@ -525,14 +525,6 @@
double generation;
ProductionInfo *prod_info;
- ctx = hal_ipod_initialize ();
- if (ctx == NULL) {
- return FALSE;
- }
- udi = g_getenv ("UDI");
- if (udi == NULL) {
- return FALSE;
- }
libhal_device_set_property_int (ctx, udi,
LIBGPOD_HAL_NS"version", 1, NULL);
@@ -640,11 +632,48 @@
}
production_info_free (prod_info);
}
- libhal_ctx_free (ctx);
return TRUE;
}
+static gboolean hal_mounted_ipod_set_properties (LibHalContext *ctx,
+ const char *udi,
+ const char *ipod_mountpoint)
+{
+ Itdb_iTunesDB *itdb;
+ Itdb_Playlist *mpl;
+ char *control_path;
+
+ itdb = itdb_parse (ipod_mountpoint, NULL);
+ if (itdb == NULL) {
+ return FALSE;
+ }
+ control_path = itdb_get_control_dir (ipod_mountpoint);
+ if (control_path != NULL) {
+ if (strlen (control_path) >= strlen (ipod_mountpoint)) {
+ libhal_device_set_property_string (ctx, udi,
+ LIBGPOD_HAL_NS"ipod.model.control_path",
+ control_path + strlen (ipod_mountpoint),
+ NULL);
+ g_free (control_path);
+ }
+ }
+
+ mpl = itdb_playlist_mpl (itdb);
+ if (mpl == NULL) {
+ return FALSE;
+ }
+ if (mpl->name != NULL) {
+ libhal_device_set_property_string (ctx, udi, "info.desktop.name",
+ mpl->name, NULL);
+ }
+
+ libhal_device_set_property_string (ctx, udi, "info.product",
+ mpl->name, NULL);
+ return FALSE;
+}
+
+
static char *mount_ipod (const char *dev_path)
{
char *filename;
@@ -699,11 +728,14 @@
return result;
}
+
int main (int argc, char **argv)
{
char *ipod_mountpoint;
char *xml;
SysInfoIpodProperties *props;
+ LibHalContext *ctx;
+ const char *udi;
g_type_init ();
@@ -712,19 +744,41 @@
return -1;
}
- props = itdb_sysinfo_extended_parse_from_xml (xml, NULL);
- hal_ipod_set_properties (props);
- itdb_sysinfo_properties_free (props);
+ props = itdb_sysinfo_extended_parse_from_xml (xml, NULL);
+ ctx = hal_ipod_initialize ();
+ if (ctx == NULL) {
+ itdb_sysinfo_properties_free (props);
+ return FALSE;
+ }
+ udi = g_getenv ("UDI");
+ if (udi == NULL) {
+ libhal_ctx_free (ctx);
+ itdb_sysinfo_properties_free (props);
+ return FALSE;
+ }
+ hal_ipod_set_properties (ctx, udi, props);
+ itdb_sysinfo_properties_free (props);
+
ipod_mountpoint = mount_ipod (g_getenv ("HAL_PROP_BLOCK_DEVICE"));
if (ipod_mountpoint == NULL) {
g_free (xml);
+ libhal_ctx_free (ctx);
return -1;
}
write_sysinfo_extended (ipod_mountpoint, xml);
g_free (xml);
+ /* hal_mounted_ipod_set_properties will call itdb_parse on the ipod
+ * which we just mounted, which will create an ItdbDevice
+ * containing most of what 'dev' had above. For now, I'm leaving
+ * this kind of duplication since I want the hal information to be
+ * added even if for some reason we don't manage to mount the ipod
+ */
+ hal_mounted_ipod_set_properties (ctx, udi, ipod_mountpoint);
+ libhal_ctx_free (ctx);
+
umount (ipod_mountpoint);
g_rmdir (ipod_mountpoint);
g_free (ipod_mountpoint);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of
expert-led, hands-on workshops and two days of sessions from industry
leaders in dedicated Performance & Operations tracks. Use code vel09scf
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2