kautomount.cpp
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 m_bShowFilemanagerWindow = _show_filemanager_window;
00039
00040 KIO::Job* job = KIO::mount( _readonly, _format.ascii(), _device, _mountpoint );
00041 connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotResult( KIO::Job * ) ) );
00042 }
00043
00044 void KAutoMount::slotResult( KIO::Job * job )
00045 {
00046 if ( job->error() ) {
00047 emit error();
00048 job->showErrorDialog();
00049 }
00050 else
00051 {
00052 KURL mountpoint;
00053 mountpoint.setPath( KIO::findDeviceMountPoint( m_strDevice ) );
00054
00055 if ( m_bShowFilemanagerWindow )
00056 KRun::runURL( mountpoint, "inode/directory" );
00057
00058
00059 KDirNotify_stub allDirNotify("*", "KDirNotify*");
00060 allDirNotify.FilesAdded( mountpoint );
00061
00062
00063 kdDebug(7015) << " mount finished : updating " << m_desktopFile << endl;
00064 KURL dfURL;
00065 dfURL.setPath( m_desktopFile );
00066 allDirNotify.FilesChanged( dfURL );
00067
00068
00069 emit finished();
00070 }
00071 delete this;
00072 }
00073
00074 KAutoUnmount::KAutoUnmount( const QString & _mountpoint, const QString & _desktopFile )
00075 : m_desktopFile( _desktopFile ), m_mountpoint( _mountpoint )
00076 {
00077 KIO::Job * job = KIO::unmount( m_mountpoint );
00078 connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotResult( KIO::Job * ) ) );
00079 }
00080
00081 void KAutoUnmount::slotResult( KIO::Job * job )
00082 {
00083 if ( job->error() ) {
00084 emit error();
00085 job->showErrorDialog();
00086 }
00087 else
00088 {
00089 KDirNotify_stub allDirNotify("*", "KDirNotify*");
00090
00091 kdDebug(7015) << "unmount finished : updating " << m_desktopFile << endl;
00092 KURL dfURL;
00093 dfURL.setPath( m_desktopFile );
00094 allDirNotify.FilesChanged( dfURL );
00095
00096
00097
00098
00099
00100
00101 allDirNotify.FilesAdded( m_mountpoint );
00102
00103 emit finished();
00104 }
00105
00106 delete this;
00107 }
00108
00109 #include "kautomount.moc"
This file is part of the documentation for kdelibs Version 3.1.5.