Bug 148607

Summary: iPod model might not get written to iPods sysinfo file because of lacking permissions
Product: [Applications] amarok Reporter: Christian Ober-Blöbaum <cob>
Component: generalAssignee: Amarok Developers <amarok-bugs-dist>
Status: RESOLVED FIXED    
Severity: normal CC: dj, ruiz
Priority: NOR    
Version: 1.4.6   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: fixed version of the function IpodMediaDevice::slotIpodAction( int id )
svn diff against current svn version of the patch

Description Christian Ober-Blöbaum 2007-08-07 14:37:45 UTC
Version:           1.4.6 (using KDE KDE 3.5.6)
Installed from:    Ubuntu Packages
OS:                Linux

Setting the iPod-Model from the amarok dialog might not work -- without a clear reason for a failure being displayed.
This results in artwork not showing up on the ipod.

Cause: The sysinfo file might not be writeable for amarok due to lacking permissions.
Cause: When using HFS+ (without journal), then the sysinfo file can have different permissions that eg. the itunes db or the music.

So the normal operations are working (music, playlists etc) but the special stuff like artwork is disabled.

The actual problem is the handling in the file ipodmediadevice.cpp:
In the function slotIpodAction the selected device type is set via itdb_device_set_sysinfo from libgpod. Afterwards the model is detected again to get the result.
BUT: since itdb_device_set_sysinfo does not actually write the updated sysinfo file the problem occurs not until the ipod detection -- leaving no real trace, what went wrong.

A possible solution would be to write the sysinfo file explicitly after changing the model by calling itdb_device_write_sysinfo from itdb.h. That function has a return value that can be checked in place - this enables amarok to raise an error message that would really help the user to solve the problem (by changing the access rights).
Comment 1 Christian Ober-Blöbaum 2007-08-08 14:08:50 UTC
Today I implemented the described solution myself and tested it - it is working as expected: when the sysinfo file could not be written (so the ipod model is not set successfully) then an error message is raised giving the user a hint that something is actually NOT right and also pointing him to a solution:

So in ipodmediadevice.cpp in the function slotIpodAction after this lines:
                    itdb_device_set_sysinfo( m_itdb->device,
                            "ModelNumStr", model );

add the following code:

                    GError *err = 0; 
                    gboolean success = tdb_device_write_sysinfo(m_itdb->device, &err);
                    debug() << "itdb_device_write_sysinfo - success: " << access << endl;
                    if( !success && err )
                    {
                        g_error_free(err);
                        Amarok::StatusBar::instance()->longMessage("Could not write sysinfo file to ipod (check the permissions of the file \"iPod_Control/Device/SysInfo\" on your iPod)");                        // the i18n files will have to be enhanced for the following to work                        Amarok::StatusBar::instance()->shortMessage(
                                i18n( "Unable to set iPod model to %1 GB %2 (x%3)" )
                                .arg( QString::number( table[index].capacity ),
                                    itdb_info_get_ipod_model_name_string( table[index].ipod_model ),                                    table[index].model_number ) );
                    } else{                        Amarok::StatusBar::instance()->shortMessage(                                i18n( "Setting iPod model to %1 GB %2 (x%3)" )                                .arg( QString::number( table[index].capacity ),                                    itdb_info_get_ipod_model_name_string( table[index].ipod_model ),
                                    table[index].model_number ) );
                    }
Comment 2 Christian Ober-Blöbaum 2007-08-08 14:16:49 UTC
Created attachment 21346 [details]
fixed version of the function IpodMediaDevice::slotIpodAction( int id )

The above was a little ugly - here is a file containing only the modified
function.
Adding i18n for the 2 new messages is still marked as TODO in the code.
Comment 3 Seb Ruiz 2007-08-08 14:25:55 UTC
Hi Christian

Would be happy to apply it if you can generate a diff using

svn diff

it is too difficult to maintain code when we have to slot it in places etc.

Thanks,
Seb

On 8 Aug 2007 12:16:50 -0000, Christian Ober-Blöbaum <cob@tzi.de> wrote:
[bugs.kde.org quoted mail]
Comment 4 Christian Ober-Blöbaum 2007-08-08 15:33:23 UTC
Created attachment 21347 [details]
svn diff against current svn version of the patch

svn diff against current svn version of the file

new i18n strings still marked as fixme
Comment 5 Ian Monroe 2007-08-10 18:16:46 UTC
Updating the i18n files is done automatically by the 'scripty' bot.
Comment 6 Christian Ober-Blöbaum 2007-08-22 12:14:41 UTC
Hi Seb,

I just wanted to know about the current status regarding the patch. I did not notice any changes in the amarok svn repository during the last week.

Is the patch in the attached file ready for inclusion or should anything be changed?

Greetings,
Christian.
Comment 7 Seb Ruiz 2007-08-22 13:23:11 UTC
Sorry, there is so much mail with the bugs that i must have overlooked it! I'll get on it right away.
Comment 8 Seb Ruiz 2007-08-22 14:14:17 UTC
SVN commit 703383 by seb:

iPod model might not get written to iPods sysinfo file because of lacking permissions
BUG: 148607


 M  +25 -5     ipodmediadevice.cpp  


--- branches/stable/extragear/multimedia/amarok/src/mediadevice/ipod/ipodmediadevice.cpp #703382:703383
@@ -357,11 +357,31 @@
                     itdb_device_set_sysinfo( m_itdb->device,
                             "ModelNumStr", model );
 
-                    Amarok::StatusBar::instance()->shortMessage(
-                            i18n( "Setting iPod model to %1 GB %2 (x%3)" )
-                            .arg( QString::number( table[index].capacity ),
-                                itdb_info_get_ipod_model_name_string( table[index].ipod_model ),
-                                table[index].model_number ) );
+                    GError *err = 0; 
+                    gboolean success = itdb_device_write_sysinfo(m_itdb->device, &err);
+                    debug() << "success writing sysinfo to ipod?: " << success << endl;
+                    if( !success && err )
+                    {
+                        g_error_free(err);
+                        //FIXME: update i18n files for next message
+                        Amarok::StatusBar::instance()->longMessage( 
+                                i18n( "Could not write sysinfo file to ipod (check the permissions of the file \"iPod_Control/Device/SysInfo\" on your iPod)" ) );
+
+                        //FIXME: update i18n files for next message
+                        Amarok::StatusBar::instance()->shortMessage(
+                                i18n( "Unable to set iPod model to %1 GB %2 (x%3)" )
+                                .arg( QString::number( table[index].capacity ),
+                                    itdb_info_get_ipod_model_name_string( table[index].ipod_model ),
+                                    table[index].model_number ) );
+                    } 
+                    else
+                    {
+                        Amarok::StatusBar::instance()->shortMessage(
+                                i18n( "Setting iPod model to %1 GB %2 (x%3)" )
+                                .arg( QString::number( table[index].capacity ),
+                                    itdb_info_get_ipod_model_name_string( table[index].ipod_model ),
+                                    table[index].model_number ) );
+                    }
                 }
                 detectModel();
                 MediaBrowser::instance()->updateDevices();
Comment 9 Seb Ruiz 2007-08-22 14:16:20 UTC
SVN commit 703385 by seb:

Forward port r703383
iPod model might not get written to iPods sysinfo file because of lacking permissions
CCBUG: 148607


 M  +25 -5     ipodmediadevice.cpp  


--- trunk/extragear/multimedia/amarok/src/mediadevice/ipod/ipodmediadevice.cpp #703384:703385
@@ -357,11 +357,31 @@
                     itdb_device_set_sysinfo( m_itdb->device,
                             "ModelNumStr", model );
 
-                    Amarok::StatusBar::instance()->shortMessage(
-                            i18n( "Setting iPod model to %1 GB %2 (x%3)" )
-                            .arg( QString::number( table[index].capacity ),
-                                itdb_info_get_ipod_model_name_string( table[index].ipod_model ),
-                                table[index].model_number ) );
+                    GError *err = 0; 
+                    gboolean success = itdb_device_write_sysinfo(m_itdb->device, &err);
+                    debug() << "success writing sysinfo to ipod?: " << success << endl;
+                    if( !success && err )
+                    {
+                        g_error_free(err);
+                        //FIXME: update i18n files for next message
+                        Amarok::StatusBar::instance()->longMessage( 
+                                i18n( "Could not write sysinfo file to ipod (check the permissions of the file \"iPod_Control/Device/SysInfo\" on your iPod)" ) );
+
+                        //FIXME: update i18n files for next message
+                        Amarok::StatusBar::instance()->shortMessage(
+                                i18n( "Unable to set iPod model to %1 GB %2 (x%3)" )
+                                .arg( QString::number( table[index].capacity ),
+                                    itdb_info_get_ipod_model_name_string( table[index].ipod_model ),
+                                    table[index].model_number ) );
+                    } 
+                    else
+                    {
+                        Amarok::StatusBar::instance()->shortMessage(
+                                i18n( "Setting iPod model to %1 GB %2 (x%3)" )
+                                .arg( QString::number( table[index].capacity ),
+                                    itdb_info_get_ipod_model_name_string( table[index].ipod_model ),
+                                    table[index].model_number ) );
+                    }
                 }
                 detectModel();
                 MediaBrowser::instance()->updateDevice();
Comment 10 Martin Aumueller 2007-11-13 04:29:13 UTC
*** Bug 141490 has been marked as a duplicate of this bug. ***