1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
Index: kioslave/media/libmediacommon/medium.cpp
===================================================================
--- kioslave/media/libmediacommon/medium.cpp.orig
+++ kioslave/media/libmediacommon/medium.cpp
@@ -42,6 +42,7 @@ Medium::Medium(const QString &id, const
loadUserLabel();
m_halmounted = false;
+ m_isHotplug = false;
}
Medium::Medium()
@@ -59,8 +60,9 @@ Medium::Medium()
m_properties+= QString::null; /* BASE_URL */
m_properties+= QString::null; /* MIME_TYPE */
m_properties+= QString::null; /* ICON_NAME */
-
+
m_halmounted = false;
+ m_isHotplug = false;
}
const Medium Medium::create(const QStringList &properties)
Index: kioslave/media/libmediacommon/medium.h
===================================================================
--- kioslave/media/libmediacommon/medium.h.orig
+++ kioslave/media/libmediacommon/medium.h
@@ -82,18 +82,22 @@ public:
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();
void loadUserLabel();
QStringList m_properties;
mutable bool m_halmounted;
-
+ bool m_isHotplug;
+
friend class QValueListNode<const Medium>;
};
namespace MediaManagerUtils {
- static inline QMap<QString,QString> splitOptions(const QStringList & options)
+ static inline QMap<QString,QString> splitOptions(const QStringList & options)
{
QMap<QString,QString> valids;
Index: kioslave/media/mediamanager/mediamanager.cpp
===================================================================
--- kioslave/media/mediamanager/mediamanager.cpp.orig
+++ kioslave/media/mediamanager/mediamanager.cpp
@@ -330,6 +330,54 @@ void MediaManager::slotMediumChanged(con
emit mediumChanged(name);
}
+QString MediaManager::unmountAllSuspend()
+{
+ QPtrList<Medium> list = m_mediaList.list();
+
+ QPtrList<Medium>::const_iterator it = list.begin();
+ QPtrList<Medium>::const_iterator end = list.end();
+
+ QString result;
+
+ for (; it!=end; ++it)
+ {
+ if ( (*it)->isMounted() && (*it)->isHotplug() )
+ {
+ QString tmp = unmount( (*it)->id() );
+ if ( !tmp.isEmpty() ) // umount failed
+ result = tmp;
+ else
+ m_suspendResumeMountList.append( (*it)->id() );
+ }
+ }
+
+ // return last error
+ return result;
+}
+
+QString MediaManager::remountAllResume()
+{
+ QString result;
+
+ for (QStringList::const_iterator it = m_suspendResumeMountList.begin();
+ it != m_suspendResumeMountList.end();
+ ++it)
+ {
+ const Medium *m = m_mediaList.findById(*it);
+
+ if ( m && m->needMounting() )
+ {
+ QString 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 QCString &obj)
Index: kioslave/media/mediamanager/mediamanager.h
===================================================================
--- kioslave/media/mediamanager/mediamanager.h.orig
+++ kioslave/media/mediamanager/mediamanager.h
@@ -58,6 +58,20 @@ k_dcop:
bool removableUnplug(const QString &devNode);
bool removableCamera(const QString &devNode);
+ /**
+ * Unmount manually all partitions when going to suspend
+ *
+ * @return last error if any
+ */
+ QString unmountAllSuspend();
+
+ /**
+ * Remount previously unmounted partitions in unmountAllSuspend()
+ *
+ * @return last error if any
+ */
+ QString remountAllResume();
+
k_dcop_signals:
void mediumAdded(const QString &name, bool allowNotification);
void mediumRemoved(const QString &name, bool allowNotification);
@@ -70,7 +84,7 @@ k_dcop_signals:
private slots:
void loadBackends();
-
+
void slotMediumAdded(const QString &id, const QString &name,
bool allowNotification);
void slotMediumRemoved(const QString &id, const QString &name,
@@ -85,6 +99,7 @@ private:
HALBackend *m_halbackend;
MediaDirNotify m_dirNotify;
FstabBackend *m_fstabbackend;
+ QStringList m_suspendResumeMountList;
};
#endif
Index: kioslave/media/mediamanager/halbackend.cpp
===================================================================
--- kioslave/media/mediamanager/halbackend.cpp.orig
+++ kioslave/media/mediamanager/halbackend.cpp
@@ -459,6 +459,8 @@ void HALBackend::setVolumeProperties(Med
libhal_volume_get_fstype(halVolume), /* Filesystem type */
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);
QString volume_name = QString::fromUtf8(name);
QString media_name = volume_name;
Index: kioslave/media/mediamanager/halbackend.h
===================================================================
--- kioslave/media/mediamanager/halbackend.h.orig
+++ kioslave/media/mediamanager/halbackend.h
@@ -86,6 +86,8 @@ public:
QString mount(const Medium *medium);
QString unmount(const QString &id);
+ static bool isHotplug( const QString & id );
+
private:
/**
* Append a device in the media list. This function will check if the device
|