kio
kautomount.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "kautomount.h"
00020 #include "krun.h"
00021 #include "kdirwatch.h"
00022 #include "kio/job.h"
00023 #include <kdirnotify_stub.h>
00024 #include <kdebug.h>
00025
00026
00027
00028
00029
00030
00031
00032 KAutoMount::KAutoMount( bool _readonly, const QString& _format, const QString& _device,
00033 const QString& _mountpoint, const QString & _desktopFile,
00034 bool _show_filemanager_window )
00035 : m_strDevice( _device ),
00036 m_desktopFile( _desktopFile )
00037 {
00038
00039 m_bShowFilemanagerWindow = _show_filemanager_window;
00040
00041 KIO::Job* job = KIO::mount( _readonly, _format.ascii(), _device, _mountpoint );
00042 connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotResult( KIO::Job * ) ) );
00043 }
00044
00045 void KAutoMount::slotResult( KIO::Job * job )
00046 {
00047 if ( job->error() ) {
00048 emit error();
00049 job->showErrorDialog();
00050 }
00051 else
00052 {
00053 KURL mountpoint;
00054 mountpoint.setPath( KIO::findDeviceMountPoint( m_strDevice ) );
00055
00056 Q_ASSERT( mountpoint.isValid() );
00057
00058 if ( mountpoint.path().isEmpty() )
00059 kdWarning(7015) << m_strDevice << " was correctly mounted, but KIO::findDeviceMountPoint didn't find it. "
00060 << "This looks like a bug, please report it on http://bugs.kde.org, together with your /etc/fstab line" << endl;
00061 else if ( m_bShowFilemanagerWindow )
00062 KRun::runURL( mountpoint, "inode/directory" );
00063
00064
00065 KDirNotify_stub allDirNotify("*", "KDirNotify*");
00066 allDirNotify.FilesAdded( mountpoint );
00067
00068
00069 kdDebug(7015) << " mount finished : updating " << m_desktopFile << endl;
00070 KURL dfURL;
00071 dfURL.setPath( m_desktopFile );
00072 allDirNotify.FilesChanged( dfURL );
00073
00074
00075 emit finished();
00076 }
00077 delete this;
00078 }
00079
00080 KAutoUnmount::KAutoUnmount( const QString & _mountpoint, const QString & _desktopFile )
00081 : m_desktopFile( _desktopFile ), m_mountpoint( _mountpoint )
00082 {
00083 KIO::Job * job = KIO::unmount( m_mountpoint );
00084 connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotResult( KIO::Job * ) ) );
00085 }
00086
00087 void KAutoUnmount::slotResult( KIO::Job * job )
00088 {
00089 if ( job->error() ) {
00090 emit error();
00091 job->showErrorDialog();
00092 }
00093 else
00094 {
00095 KDirNotify_stub allDirNotify("*", "KDirNotify*");
00096
00097 kdDebug(7015) << "unmount finished : updating " << m_desktopFile << endl;
00098 KURL dfURL;
00099 dfURL.setPath( m_desktopFile );
00100 allDirNotify.FilesChanged( dfURL );
00101
00102
00103
00104
00105
00106
00107 KURL mp;
00108 mp.setPath( m_mountpoint );
00109 allDirNotify.FilesAdded( mp );
00110
00111 emit finished();
00112 }
00113
00114 delete this;
00115 }
00116
00117 #include "kautomount.moc"