summaryrefslogtreecommitdiffstats
path: root/redhat/tdebase/tdebase-14.0.0-suspend_unmount.patch
blob: 01d9e479bf1ddaff6ceb808df4a314cae1e9e6fe (plain)
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
--- ./tdeioslave/media/libmediacommon/medium.cpp.ori	2013-05-08 22:57:09.317384423 +0200
+++ ./tdeioslave/media/libmediacommon/medium.cpp	2013-05-08 22:57:36.730837358 +0200
@@ -46,6 +46,7 @@
 	loadUserLabel();
 
 	m_halmounted = false;
+	m_isHotplug = false;
 }
 
 Medium::Medium()
@@ -69,6 +70,7 @@
 	m_properties+= "false";        /* HIDDEN */
 	
 	m_halmounted = false;
+	m_isHotplug = false;
 }
 
 const Medium Medium::create(const TQStringList &properties)
--- ./tdeioslave/media/libmediacommon/medium.h.ORI	2013-05-08 22:59:10.772959829 +0200
+++ ./tdeioslave/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<const Medium>;
 };
--- ./tdeioslave/media/mediamanager/mediamanager.cpp.ori	2013-05-08 23:00:39.673183801 +0200
+++ ./tdeioslave/media/mediamanager/mediamanager.cpp	2013-05-08 23:04:47.639224260 +0200
@@ -354,6 +354,57 @@
     emit mediumChanged(name);
 }
 
+TQString MediaManager::unmountAllSuspend()
+{
+    TQPtrList<Medium> list = m_mediaList.list();
+
+    TQPtrList<Medium>::const_iterator it = list.begin();
+    TQPtrList<Medium>::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)
--- ./tdeioslave/media/mediamanager/mediamanager.h.ORI	2013-05-08 23:05:36.250251036 +0200
+++ ./tdeioslave/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);
@@ -89,6 +103,7 @@
 	TDEBackend *m_tdebackend;
 	MediaDirNotify m_dirNotify;
 	FstabBackend *m_fstabbackend;
+	TQStringList m_suspendResumeMountList;
 };
 
 #endif
--- ./tdeioslave/media/mediamanager/halbackend.cpp.ori	2013-05-08 23:08:12.196126863 +0200
+++ ./tdeioslave/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);
--- ./tdeioslave/media/mediamanager/halbackend.h.ORI	2013-05-08 23:09:35.761451488 +0200
+++ ./tdeioslave/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