This forum has been archived. All content is frozen. Please use KDE Discuss instead.

[patch] ipod eject button

Tags: None
(comma "," separated)
Paul Wheeler
Karma
0

[patch] ipod eject button

Fri Aug 19, 2005 10:45 pm
I have just got an ipod mini for my girlfriend. She currently uses myth at home and has no problems with it, however she gets flumuxed like most non-linux people when having to type in a shell.

For her to be able to use the iPod I have set up an automout so that when she plugs it in it gets automatically mounted. The only thing now stopping her from using it is having to eject the ipod, hence this patch (I also filed a wishlist bug #111012 then realised I could probably program it)

This patch adds an ipod::eject() function which runs umount and then eject.

It also adds a new button \"transfer and eject\" this then transfers the files and calls the ipod::close followed by ipod::eject.

I use gentoo and add the line to the end of src_unpack():
[code:1]
epatch /root/amarok.patch
[/code:1]

to apply it when emerging.

The Patch:
[code:1]
diff -ur amarok-1.3/amarok/src/amarokcore/amarokdcophandler.cpp amarok-1.3-new/amarok/src/amarokcore/amarokdcophandler.cpp
--- amarok-1.3/amarok/src/amarokcore/amarokdcophandler.cpp 2005-08-14 23:53:18.000000000 +0100
+++ amarok-1.3-new/amarok/src/amarokcore/amarokdcophandler.cpp 2005-08-19 16:16:59.000000000 +0100
@@ -362,6 +362,11 @@
MediaDevice::instance()->transferFiles();
}

+ void DcopPlayerHandler::ejectIpod()
+ {
+ MediaDevice::instance()->ejectIpod();
+ }
+
void DcopPlayerHandler::volumeDown()
{
EngineController::instance()->decreaseVolume();
diff -ur amarok-1.3/amarok/src/amarokcore/amarokdcophandler.h amarok-1.3-new/amarok/src/amarokcore/amarokdcophandler.h
--- amarok-1.3/amarok/src/amarokcore/amarokdcophandler.h 2005-08-14 23:53:18.000000000 +0100
+++ amarok-1.3-new/amarok/src/amarokcore/amarokdcophandler.h 2005-08-19 16:31:44.000000000 +0100
@@ -87,6 +87,7 @@
virtual void volumeDown();
virtual void volumeUp();
virtual void transferDeviceFiles();
+ virtual void ejectIpod();

private:
virtual void transferCliArgs( QStringList args );
diff -ur amarok-1.3/amarok/src/ipod/ipod.cpp amarok-1.3-new/amarok/src/ipod/ipod.cpp
--- amarok-1.3/amarok/src/ipod/ipod.cpp 2005-08-14 23:53:18.000000000 +0100
+++ amarok-1.3-new/amarok/src/ipod/ipod.cpp 2005-08-19 15:44:40.000000000 +0100
@@ -53,6 +53,17 @@
itunesdb.clear();
}

+void IPod::eject() {
+ QString exec_command;
+
+ exec_command = \"umount \" + ipodBase;
+ system(exec_command.latin1());
+
+ exec_command = \"eject \" + ipodBase;
+ system(exec_command.latin1());
+
+}
+

bool IPod::ensureConsistency() {
kdDebug() sizeHint().height() );
m_progress->hide();

+ QHBox* eb( this );
+ eb->setSpacing( 4 );
+ m_ejectButton = new QPushButton( SmallIconSet( \"rebuild\" ), i18n( \"Transfer and Eject\" ), eb );
+
connect( m_transferButton, SIGNAL( clicked() ), MediaDevice::instance(), SLOT( transferFiles() ) );
+ connect( m_ejectButton, SIGNAL( clicked() ), MediaDevice::instance(), SLOT( ejectIpod() ) );
}


@@ -580,6 +585,21 @@
void
MediaDevice::transferFiles() //SLOT
{
+ transferFiles(0);
+}
+
+
+void
+MediaDevice::ejectIpod() //SLOT
+{
+ transferFiles(1);
+}
+
+
+void
+MediaDevice::transferFiles( int eject )
+{
+ m_parent->m_ejectButton->setEnabled( false );
m_parent->m_transferButton->setEnabled( false );

if ( m_ipod->ensureConsistency() )
@@ -629,11 +649,16 @@
m_ipod->unlock();
syncIPod();
fileTransferFinished();
+ if (eject==1) {
+ m_ipod->close();
+ m_ipod->eject();
+ }
}
else
debug() setEnabled( true );
+ m_parent->m_ejectButton->setEnabled( true );
}


diff -ur amarok-1.3/amarok/src/mediabrowser.h amarok-1.3-new/amarok/src/mediabrowser.h
--- amarok-1.3/amarok/src/mediabrowser.h 2005-08-14 23:53:18.000000000 +0100
+++ amarok-1.3-new/amarok/src/mediabrowser.h 2005-08-19 16:10:21.000000000 +0100
@@ -109,6 +109,7 @@
MediaDeviceList* m_deviceList;
KListView* m_transferList;
QPushButton* m_transferButton;
+ QPushButton* m_ejectButton;

MediaBrowser* m_parent;
};
@@ -133,6 +134,7 @@

public slots:
void transferFiles();
+ void ejectIpod();
void deleteFiles( const KURL::List& urls );
void deleteFromIPod( MediaItem* item );

@@ -143,6 +145,7 @@

private:
void openIPod();
+ void transferFiles( int eject );
bool fileExists( const MetaBundle& bundle );
KURL::List m_transferURLs;

[/code:1]

I welcome any comments on this code. I think this feature and the ability to add playlists are the two that stop amarok from being a great program to use with an ipod.
Paul Wheeler
Karma
0

Re:[patch] ipod eject button

Fri Aug 19, 2005 10:48 pm
Forgot to say this only works for me if I have eject setuid root, so it runs as root. Looking at the eject website this seems to be an issue with eject.
User avatar
eean
KDE Developer
Posts
1016
Karma
0
OS

Re:[patch] ipod eject button

Sat Aug 20, 2005 2:34 am
My two cents is to use one of the KDE APIs instead of system(). We try to avoid scary C lib stuff.

You should submit this is a wish request on bugzilla and attach the patch.


Amarok Developer
Psy
Karma
0

Re:[patch] ipod eject button

Mon Aug 22, 2005 7:11 am
Is there any KDE program/funktion to eject an iPod yet? I\'m experiencing the same problem like mentioned above.
Mike Diehl
Registered Member
Posts
87
Karma
0

Re:[patch] ipod eject button

Sat Aug 27, 2005 9:15 am
I implemented mount/umounting in the Media Device browser using the connect button in current svn. To eject the iPod you need to do this.

#chmod a+rsx /path/to/eject

And then in the Media Device config dialog set

\"eject /path/of/mount\" for the unmount command.

The eject command umounts before eject, I\'ve tested this and it works great. ;)

Post edited by: madpenguin8, at: 2005/08/27 05:20
User avatar
eean
KDE Developer
Posts
1016
Karma
0
OS

Re:[patch] ipod eject button

Sat Aug 27, 2005 1:34 pm
Well, rather the suid eject I believe you can various options to your fstab. I don\'t have a iPod, but I can eject with my non-suid `eject` with:
/dev/cdroms/cdrom0 /mnt/dvd iso9660 noauto,ro,users 0 0

I believe the key option there is \"users\"


Amarok Developer
zekant
Registered Member
Posts
34
Karma
0

Re:[patch] ipod eject button

Sat Aug 27, 2005 2:30 pm
Yep, but without an \"s\" in the end :)

My 2 cents :whistle:
Mike Diehl
Registered Member
Posts
87
Karma
0

Re:[patch] ipod eject button

Sat Aug 27, 2005 4:15 pm
Sorry, but that\'s wrong. Yes my non-suid eject can eject the cdrom, but in no way can it eject a scsi device regardless of fstab entry.

└─(~)-> eject /mnt/ipod/
eject: unable to open `/dev/scsi/host17/bus0/target0/lun0/part2\'

From the eject man page.

You need appropriate privileges to access the device files. Running as root or setuid root is required to eject some devices (e.g. SCSI devices).
User avatar
eean
KDE Developer
Posts
1016
Karma
0
OS

Re:[patch] ipod eject button

Sat Aug 27, 2005 9:17 pm
Ah, OK.


Amarok Developer
User avatar
Francis Belanger
Registered Member
Posts
47
Karma
0

Re:[patch] ipod eject button

Fri Sep 23, 2005 8:21 pm
The temporary way I did it now is to add a sudoer so I can write :

sudo eject /dev/IpodDeviceName

and it ask my user password but it\'s better than to have to type the root password.


Bookmarks



Who is online

Registered users: bancha, Bing [Bot], daret, Evergrowing, Google [Bot], lockheed, sandyvee, Sogou [Bot]