--- ./kioslave/media/libmediacommon/medium.cpp.ori 2013-05-08 22:57:09.317384423 +0200 +++ ./kioslave/media/libmediacommon/medium.cpp 2013-05-08 22:57:36.730837358 +0200 @@ -44,6 +44,7 @@ loadUserLabel(); m_halmounted = false; + m_isHotplug = false; } Medium::Medium() @@ -65,6 +66,7 @@ m_properties+= TQString::null; /* CLEAR_DEVICE_UDI */ m_halmounted = false; + m_isHotplug = false; } const Medium Medium::create(const TQStringList &properties) --- ./kioslave/media/libmediacommon/medium.h.ORI 2013-05-08 22:59:10.772959829 +0200 +++ ./kioslave/media/libmediacommon/medium.h 2013-05-08 22:59:56.602044404 +0200 @@ -92,6 +92,9 @@ void setHalMounted(bool flag) const { m_halmounted = flag; } bool halMounted() const { return m_halmounted; } + void setIsHotplug( bool state ) { m_isHotplug = state; } + bool isHotplug() const { return m_isHotplug; } + //private: Medium(); @@ -100,6 +103,8 @@ TQStringList m_properties; mutable bool m_halmounted; + + bool m_isHotplug; friend class TQValueListNode; }; --- ./kioslave/media/mediamanager/mediamanager.cpp.ori 2013-05-08 23:00:39.673183801 +0200 +++ ./kioslave/media/mediamanager/mediamanager.cpp 2013-05-08 23:04:47.639224260 +0200 @@ -354,6 +354,57 @@ emit mediumChanged(name); } +TQString MediaManager::unmountAllSuspend() +{ + TQPtrList list = m_mediaList.list(); + + TQPtrList::const_iterator it = list.begin(); + TQPtrList::const_iterator end = list.end(); + + TQString result; + + for (; it!=end; ++it) + { + if ( (*it)->isMounted() && (*it)->isHotplug() ) + { + TQString tmp = unmount( (*it)->id() ); + if ( !tmp.isEmpty() ) { // umount failed + result = tmp; + } else { + m_suspendResumeMountList.append( (*it)->id() ); + } + } + } + + // return last error + return result; +} + +TQString MediaManager::remountAllResume() +{ + TQString result; + + for (TQStringList::const_iterator it = m_suspendResumeMountList.begin(); + it != m_suspendResumeMountList.end(); + ++it) + { + const Medium *m = m_mediaList.findById(*it); + + if ( m && m->needMounting() ) + { + TQString tmp = mount( *it ); + if ( !tmp.isEmpty() ) { // mount failed + result = tmp; + } + } + } + + m_suspendResumeMountList.clear(); + + // return last error + return result; +} + extern "C" { KDE_EXPORT KDEDModule *create_mediamanager(const TQCString &obj) --- ./kioslave/media/mediamanager/mediamanager.h.ORI 2013-05-08 23:05:36.250251036 +0200 +++ ./kioslave/media/mediamanager/mediamanager.h 2013-05-08 23:07:27.650019601 +0200 @@ -60,6 +60,20 @@ bool removableUnplug(const TQString &devNode); bool removableCamera(const TQString &devNode); + /** + * Unmount manually all partitions when going to suspend + * + * @return last error if any + */ + TQString unmountAllSuspend(); + + /** + * Remount previously unmounted partitions in unmountAllSuspend() + * + * @return last error if any + */ + TQString remountAllResume(); + k_dcop_signals: void mediumAdded(const TQString &name, bool allowNotification); void mediumRemoved(const TQString &name, bool allowNotification); @@ -87,6 +101,8 @@ HALBackend *m_halbackend; MediaDirNotify m_dirNotify; FstabBackend *m_fstabbackend; + TQStringList m_suspendResumeMountList; + }; #endif --- ./kioslave/media/mediamanager/halbackend.cpp.ori 2013-05-08 23:08:12.196126863 +0200 +++ ./kioslave/media/mediamanager/halbackend.cpp 2013-05-08 23:08:51.096347073 +0200 @@ -541,6 +541,7 @@ libhal_volume_is_mounted(halVolume) ); /* Mounted ? */ } + medium->setIsHotplug( libhal_drive_is_hotpluggable(halDrive) ); char* name = libhal_volume_policy_compute_display_name(halDrive, halVolume, m_halStoragePolicy); TQString volume_name = TQString::fromUtf8(name); --- ./kioslave/media/mediamanager/halbackend.h.ORI 2013-05-08 23:09:35.761451488 +0200 +++ ./kioslave/media/mediamanager/halbackend.h 2013-05-08 23:10:21.608531952 +0200 @@ -89,6 +89,8 @@ TQString decrypt(const TQString &id, const TQString &password); TQString undecrypt(const TQString &id); + static bool isHotplug( const TQString & id ); + private: /** * Append a device in the media list. This function will check if the device