[PATCH] [python] Include device->timezone_shift in sw_ipod_device_to_dict()

Adeodato Simó <[email protected]> Tue, 31 May 2011 04:12:15 +0100
Newsgroups gmane.comp.ipod.gtkpod
Message-ID <7441a7511496dbe0c292c7a2f87ffa79fb8e1bb3.1306810985.git.dato@net.com.org.es>
---
Hi,

as a follow-up to my other path, it seems I cannot access the "timezone_shift"
member of Itdb_Device via Python:

    >>> d
    <gpod.gpod._Itdb_iTunesDB; proxy of <Swig Object of type '_Itdb_iTunesDB *' at 0x24feea0> >

    >>> d.device
    <Swig Object of type 'Itdb_Device *' at 0x36272d0>

    >>> d.device.timezone_shift
    AttributeError: 'SwigPyObject' object has no attribute 'timezone_shift'

My suspicion is it has to do with the way Itdb_Device is a typedef for
_Itdb_Device, and perhaps SWIG is not groking that (note how "d"
properly says it's an _Itdb_iTunesDB object, but "d.device" is an
Itdb_Device instead, i.e. not the real struct).

I don't have enough SWIG-fu to fix this, but I notice a function
sw_ipod_device_to_dict function exists that helps retrieve data from
Itdb_Device objects. This patch trivially adds the missing
timezone_shift there.

 bindings/python/gpod.i.in |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/bindings/python/gpod.i.in b/bindings/python/gpod.i.in
index 1b5d5f5..0a8b454 100644
--- a/bindings/python/gpod.i.in
+++ b/bindings/python/gpod.i.in
@@ -269,7 +269,7 @@ PyObject* sw_get_photo(GList *list, gint index) {
      g_hash_table_foreach(device->sysinfo, 
 			  hash_table_to_pydict, 
 			  (gpointer) sysinfo);
-     return Py_BuildValue("{s:s,s:i,s:i,s:O}",
+     return Py_BuildValue("{s:s,s:i,s:i,s:O,s:i}",
 			  "mountpoint",
 			  device->mountpoint,
 			  "musicdirs",
@@ -277,7 +277,9 @@ PyObject* sw_get_photo(GList *list, gint index) {
 			  "byte_order",
 			  device->byte_order,
 			  "sysinfo",
-			  sysinfo);
+			  sysinfo,
+                          "timezone_shift",
+                          device->timezone_shift);
    }
  }
 
-- 
1.7.2.3


------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger. 
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today. 
http://p.sf.net/sfu/quest-sfdev2dev