• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeio/tdeio
 

tdeio/tdeio

  • tdeio
  • tdeio
kautomount.cpp
1/* This file is part of the KDE libraries
2 Copyright (C) 2000 David Faure <faure@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
7
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
12
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
17*/
18
19#include "kautomount.h"
20#include "krun.h"
21#include "kdirwatch.h"
22#include "tdeio/job.h"
23#include <kdirnotify_stub.h>
24#include <kdebug.h>
25
26/***********************************************************************
27 *
28 * Utility classes
29 *
30 ***********************************************************************/
31
32KAutoMount::KAutoMount( bool _readonly, const TQString& _format, const TQString& _device,
33 const TQString& _mountpoint, const TQString & _desktopFile,
34 bool _show_filemanager_window )
35 : m_strDevice( _device ),
36 m_desktopFile( _desktopFile )
37{
38 //kdDebug(7015) << "KAutoMount device=" << _device << " mountpoint=" << _mountpoint << endl;
39 m_bShowFilemanagerWindow = _show_filemanager_window;
40
41 TDEIO::Job* job = TDEIO::mount( _readonly, _format.ascii(), _device, _mountpoint );
42 connect( job, TQ_SIGNAL( result( TDEIO::Job * ) ), this, TQ_SLOT( slotResult( TDEIO::Job * ) ) );
43}
44
45void KAutoMount::slotResult( TDEIO::Job * job )
46{
47 if ( job->error() ) {
48 emit error();
49 job->showErrorDialog();
50 }
51 else
52 {
53 KURL mountpoint;
54 mountpoint.setPath( TDEIO::findDeviceMountPoint( m_strDevice ) );
55 //kdDebug(7015) << "KAutoMount: m_strDevice=" << m_strDevice << " -> mountpoint=" << mountpoint << endl;
56 Q_ASSERT( mountpoint.isValid() );
57
58 if ( mountpoint.path().isEmpty() )
59 kdWarning(7015) << m_strDevice << " was correctly mounted, but TDEIO::findDeviceMountPoint didn't find it. "
60 << "This looks like a bug, please report it on http://bugs.trinitydesktop.org, together with your /etc/fstab line" << endl;
61 else if ( m_bShowFilemanagerWindow )
62 KRun::runURL( mountpoint, "inode/directory" );
63
64 // Notify about the new stuff in that dir, in case of opened windows showing it
65 KDirNotify_stub allDirNotify("*", "KDirNotify*");
66 allDirNotify.FilesAdded( mountpoint );
67
68 // Update the desktop file which is used for mount/unmount (icon change)
69 kdDebug(7015) << " mount finished : updating " << m_desktopFile << endl;
70 KURL dfURL;
71 dfURL.setPath( m_desktopFile );
72 allDirNotify.FilesChanged( dfURL );
73 //KDirWatch::self()->setFileDirty( m_desktopFile );
74
75 emit finished();
76 }
77 delete this;
78}
79
80KAutoUnmount::KAutoUnmount( const TQString & _mountpoint, const TQString & _desktopFile )
81 : m_desktopFile( _desktopFile ), m_mountpoint( _mountpoint )
82{
83 TDEIO::Job * job = TDEIO::unmount( m_mountpoint );
84 connect( job, TQ_SIGNAL( result( TDEIO::Job * ) ), this, TQ_SLOT( slotResult( TDEIO::Job * ) ) );
85}
86
87void KAutoUnmount::slotResult( TDEIO::Job * job )
88{
89 if ( job->error() ) {
90 emit error();
91 job->showErrorDialog();
92 }
93 else
94 {
95 KDirNotify_stub allDirNotify("*", "KDirNotify*");
96 // Update the desktop file which is used for mount/unmount (icon change)
97 kdDebug(7015) << "unmount finished : updating " << m_desktopFile << endl;
98 KURL dfURL;
99 dfURL.setPath( m_desktopFile );
100 allDirNotify.FilesChanged( dfURL );
101 //KDirWatch::self()->setFileDirty( m_desktopFile );
102
103 // Notify about the new stuff in that dir, in case of opened windows showing it
104 // You may think we removed files, but this may have also readded some
105 // (if the mountpoint wasn't empty). The only possible behavior on FilesAdded
106 // is to relist the directory anyway.
107 KURL mp;
108 mp.setPath( m_mountpoint );
109 allDirNotify.FilesAdded( mp );
110
111 emit finished();
112 }
113
114 delete this;
115}
116
117#include "kautomount.moc"
KAutoMount::error
void error()
Emitted in case the directory could not been mounted.
KAutoMount::finished
void finished()
Emitted when the directory has been mounted.
KAutoMount::KAutoMount
KAutoMount(bool readonly, const TQString &format, const TQString &device, const TQString &mountpoint, const TQString &desktopFile, bool show_filemanager_window=true)
Mounts a device.
Definition kautomount.cpp:32
KAutoUnmount::error
void error()
Emitted in case the directory could not been unmounted.
KAutoUnmount::finished
void finished()
Emitted when the directory has been unmounted.
KAutoUnmount::KAutoUnmount
KAutoUnmount(const TQString &mountpoint, const TQString &desktopFile)
Unmounts a device.
Definition kautomount.cpp:80
KRun::runURL
static pid_t runURL(const KURL &_url, const TQString &_mimetype, bool tempFile, bool runExecutables)
Open the given URL.
Definition krun.cpp:94
TDEIO::Job
The base class for all jobs.
Definition jobclasses.h:67
TDEIO::Job::showErrorDialog
void showErrorDialog(TQWidget *parent=0L)
Display a dialog box to inform the user of the error given by this job.
Definition job.cpp:315
TDEIO::Job::error
int error() const
Returns the error code, if there has been an error.
Definition jobclasses.h:94
TDEIO::findDeviceMountPoint
TDEIO_EXPORT TQString findDeviceMountPoint(const TQString &device)
Returns the mount point where device is mounted right now.
Definition global.cpp:1401
TDEIO::unmount
TDEIO_EXPORT SimpleJob * unmount(const TQString &point, bool showProgressInfo=true)
Unmount filesystem.
Definition job.cpp:831
TDEIO::mount
TDEIO_EXPORT SimpleJob * mount(bool ro, const char *fstype, const TQString &dev, const TQString &point, bool showProgressInfo=true)
Mount filesystem.
Definition job.cpp:821

tdeio/tdeio

Skip menu "tdeio/tdeio"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdeio/tdeio

Skip menu "tdeio/tdeio"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeio/tdeio by doxygen 1.9.8
This website is maintained by Timothy Pearson.