12 Commits

Author SHA1 Message Date
  Michele Calgaro b9bd2490e5
Added initial support for unlocking/locking of encrypted devices. 1 month ago
  Michele Calgaro 6ffe594763
Renamed methods decrypt/undecrypt to unlock/lock. 1 month ago
  Michele Calgaro 403bb4e2ec
Extended media manager dcop interface by adding functions to 1 month ago
  Michele Calgaro d9690f5f12
Improved media manager dcop interface for mount/unmount/decrypt/undecrypt methods by returning more information. 1 month ago
  Michele Calgaro 20957ced9c
Adjusted to use new TQStringVariantMap type. 1 month ago
  Michele Calgaro 1fca3a6697
Adjusted to new TDEStorageOpResult-based tdelibs api. 1 month ago
  Michele Calgaro c393eecadb
mediamanager: cleaned up use of medium name map. 1 month ago
  Michele Calgaro b430396275
Renamed methods decrypt/undecrypt to unlock/lock. 1 month ago
  Michele Calgaro c8897a02b7
Extended media manager dcop interface by adding functions to 1 month ago
  Michele Calgaro 7a43cd12af
Improved media manager dcop interface for mount/unmount/decrypt/undecrypt methods by returning more information. 1 month ago
  Michele Calgaro 2c9b8f321a
Adjusted to use new TQStringVariantMap type. 1 month ago
  Michele Calgaro cf748b1827
Adjusted to new TDEStorageOpResult-based tdelibs api. 1 month ago

+ 2
- 4
tdeioslave/media/mediamanager/halbackend.cpp View File

@@ -1398,7 +1398,6 @@ void HALBackend::slotResult(TDEIO::Job *job)
1398 1398
     if (job->error() == TDEIO::ERR_COULD_NOT_UNMOUNT) {
1399 1399
         TQString proclist(listUsingProcesses(medium));
1400 1400
 
1401
-        qerror = "<qt>";
1402 1401
         qerror += "<p>" + i18n("Unfortunately, the device <b>%1</b> (%2) named <b>'%3'</b> and "
1403 1402
                        "currently mounted at <b>%4</b> could not be unmounted. ").arg(
1404 1403
                           "system:/media/" + medium->name(),
@@ -1411,7 +1410,6 @@ void HALBackend::slotResult(TDEIO::Job *job)
1411 1410
         if (!proclist.isEmpty()) {
1412 1411
             qerror += proclist;
1413 1412
         }
1414
-        qerror += "</qt>";
1415 1413
     } else if (job->error()) {
1416 1414
         qerror = job->errorText();
1417 1415
     }
@@ -1815,7 +1813,7 @@ TQStringVariantMap HALBackend::unlock(const TQString &id, const TQString &passwo
1815 1813
         return result;
1816 1814
     }
1817 1815
 
1818
-    if (!medium->isEncrypted() || !medium->clearDeviceUdi().isNull())
1816
+    if (!medium->isEncrypted() || !medium->clearDeviceUdi().isNull()) {
1819 1817
         result["result"] = true;
1820 1818
         return result;
1821 1819
     }
@@ -1884,7 +1882,7 @@ TQStringVariantMap HALBackend::lock(const TQString &id)
1884 1882
         return result;
1885 1883
     }
1886 1884
 
1887
-    if (!medium->isEncrypted() || !medium->clearDeviceUdi().isNull())
1885
+    if (!medium->isEncrypted() || !medium->clearDeviceUdi().isNull()) {
1888 1886
         result["result"] = true;
1889 1887
         return result;
1890 1888
     }

+ 0
- 6
tdeioslave/media/mediamanager/mediamanager.cpp View File

@@ -297,7 +297,6 @@ TQStringVariantMap MediaManager::unmount(const TQString &uid)
297 297
 TQStringVariantMap MediaManager::unlock(const TQString &uid, const TQString &password)
298 298
 {
299 299
 	TQStringVariantMap result;
300
-/*
301 300
 #ifdef COMPILE_TDEHARDWAREBACKEND
302 301
 	if (!m_tdebackend) {
303 302
 		result["errStr"] = i18n("Feature only available with the TDE hardware backend");
@@ -306,8 +305,6 @@ TQStringVariantMap MediaManager::unlock(const TQString &uid, const TQString &pas
306 305
 	}
307 306
 	return m_tdebackend->unlock(uid, password);
308 307
 #elif defined COMPILE_HALBACKEND
309
-*/
310
-#if defined COMPILE_HALBACKEND
311 308
 	if (!m_halbackend) {
312 309
 		result["errStr"] = i18n("Feature only available with HAL");
313 310
 		result["result"] = false;
@@ -328,7 +325,6 @@ TQStringVariantMap MediaManager::unlock(const TQString &uid, const TQString &pas
328 325
 TQStringVariantMap MediaManager::lock(const TQString &uid)
329 326
 {
330 327
 	TQStringVariantMap result;
331
-/*
332 328
 #ifdef COMPILE_TDEHARDWAREBACKEND
333 329
 	if (!m_tdebackend) {
334 330
 		result["errStr"] = i18n("Feature only available with the TDE hardware backend");
@@ -337,8 +333,6 @@ TQStringVariantMap MediaManager::lock(const TQString &uid)
337 333
 	}
338 334
 	return m_tdebackend->lock(uid);
339 335
 #elif defined COMPILE_HALBACKEND
340
-*/
341
-#if defined COMPILE_HALBACKEND
342 336
 	if (!m_halbackend) {
343 337
 		result["errStr"] = i18n("Feature only available with HAL");
344 338
 		result["result"] = false;

+ 82
- 3
tdeioslave/media/mediamanager/tdehardwarebackend.cpp View File

@@ -1438,7 +1438,7 @@ TQStringVariantMap TDEBackend::unmount(const TQString &id)
1438 1438
 		// Failed as BUSY
1439 1439
 		TQString processesUsingDev = listUsingProcesses(medium);
1440 1440
 		if (!processesUsingDev.isNull()) {
1441
-			if (KMessageBox::warningYesNo(0, i18n("<qt>The device <b>%1</b> (%2) named <b>'%3'</b> and currently "
1441
+			if (KMessageBox::warningYesNo(0, i18n("The device <b>%1</b> (%2) named <b>'%3'</b> and currently "
1442 1442
 			    "mounted at <b>%4</b> can not be unmounted at this time.<p>%5<p><b>Would you like to forcibly "
1443 1443
 			    "terminate these processes?</b><br><i>All unsaved data would be lost</i>").arg("system:/media/" +
1444 1444
 			    medium->name()).arg(medium->deviceNode()).arg(medium->prettyLabel()).arg(medium->prettyBaseURL().pathOrURL())
@@ -1477,6 +1477,87 @@ TQStringVariantMap TDEBackend::unmount(const TQString &id)
1477 1477
 	return result;
1478 1478
 }
1479 1479
 
1480
+TQStringVariantMap TDEBackend::unlock(const TQString &id, const TQString &password)
1481
+{
1482
+	TQStringVariantMap result;
1483
+
1484
+	const Medium* medium = m_mediaList.findById(id);
1485
+	if (!medium) {
1486
+		result["errStr"] = i18n("No such medium: %1").arg(id);
1487
+		result["result"] = false;
1488
+		return result;
1489
+	}
1490
+
1491
+	if (!medium->isEncrypted() || !medium->clearDeviceUdi().isNull()) {
1492
+		result["result"] = true;
1493
+		return result;
1494
+	}
1495
+
1496
+	TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
1497
+	TDEStorageDevice *sdevice = hwdevices->findDiskByUID(medium->id());
1498
+	if (!sdevice) {
1499
+		result["errStr"] = i18n("Internal error. Couldn't find medium.");
1500
+		result["result"] = false;
1501
+		return result;
1502
+	}
1503
+
1504
+	TQStringVariantMap unlockResult = sdevice->unlockDevice(password);
1505
+	if (unlockResult["result"].toBool() == false) {
1506
+		TQString qerror = i18n("Unable to unlock the device.");
1507
+		TQString errStr = unlockResult.contains("errStr") ? unlockResult["errStr"].toString() : TQString::null;
1508
+		if (!errStr.isEmpty()) {
1509
+			qerror.append(i18n("<p>Technical details:<br>").append(errStr));
1510
+		result["errStr"] = qerror;
1511
+		result["result"] = false;
1512
+		return result;
1513
+		}
1514
+	}
1515
+
1516
+	result["result"] = unlockResult["unlockedDevice"];
1517
+	result["result"] = true;
1518
+	return result;
1519
+}
1520
+
1521
+TQStringVariantMap TDEBackend::lock(const TQString &id)
1522
+{
1523
+	TQStringVariantMap result;
1524
+
1525
+	const Medium* medium = m_mediaList.findById(id);
1526
+	if (!medium) {
1527
+		result["errStr"] = i18n("No such medium: %1").arg(id);
1528
+		result["result"] = false;
1529
+		return result;
1530
+	}
1531
+
1532
+	if (!medium->isEncrypted() || !medium->clearDeviceUdi().isNull()) {
1533
+		result["result"] = true;
1534
+		return result;
1535
+	}
1536
+
1537
+	TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
1538
+	TDEStorageDevice *sdevice = hwdevices->findDiskByUID(medium->id());
1539
+	if (!sdevice) {
1540
+		result["errStr"] = i18n("Internal error. Couldn't find medium.");
1541
+		result["result"] = false;
1542
+		return result;
1543
+	}
1544
+
1545
+	TQStringVariantMap lockResult = sdevice->lockDevice();
1546
+	if (lockResult["result"].toBool() == false) {
1547
+		TQString qerror = i18n("Unable to lock the device.");
1548
+		TQString errStr = lockResult.contains("errStr") ? lockResult["errStr"].toString() : TQString::null;
1549
+		if (!errStr.isEmpty()) {
1550
+			qerror.append(i18n("<p>Technical details:<br>").append(errStr));
1551
+		result["errStr"] = qerror;
1552
+		result["result"] = false;
1553
+		return result;
1554
+		}
1555
+	}
1556
+
1557
+	result["result"] = true;
1558
+	return result;
1559
+}
1560
+
1480 1561
 void TDEBackend::slotResult(TDEIO::Job *job)
1481 1562
 {
1482 1563
 	TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
@@ -1488,7 +1569,6 @@ void TDEBackend::slotResult(TDEIO::Job *job)
1488 1569
 	if (job->error() == TDEIO::ERR_COULD_NOT_UNMOUNT) {
1489 1570
 		TQString proclist(listUsingProcesses(medium));
1490 1571
 
1491
-		qerror = "<qt>";
1492 1572
 		qerror += "<p>" + i18n("Unfortunately, the device <b>%1</b> (%2) named <b>'%3'</b> and "
1493 1573
 			"currently mounted at <b>%4</b> could not be unmounted. ").arg(
1494 1574
 				"system:/media/" + medium->name(),
@@ -1501,7 +1581,6 @@ void TDEBackend::slotResult(TDEIO::Job *job)
1501 1581
 		if (!proclist.isEmpty()) {
1502 1582
 			qerror += proclist;
1503 1583
 		}
1504
-		qerror += "</qt>";
1505 1584
 	} else if (job->error()) {
1506 1585
 		qerror = job->errorText();
1507 1586
 	}

+ 2
- 2
tdeioslave/media/mediamanager/tdehardwarebackend.h View File

@@ -71,8 +71,8 @@ public:
71 71
 	TQStringVariantMap mount(const TQString &id);
72 72
 	TQStringVariantMap mount(const Medium *medium);
73 73
 	TQStringVariantMap unmount(const TQString &id);
74
-// 	TQStringVariantMap unlock(const TQString &id, const TQString &password);
75
-// 	TQStringVariantMap lock(const TQString &id);
74
+	TQStringVariantMap unlock(const TQString &id, const TQString &password);
75
+	TQStringVariantMap lock(const TQString &id);
76 76
 
77 77
 private:
78 78
 	/**

+ 1
- 1
tdeioslave/media/mounthelper/decryptdialog.ui View File

@@ -107,7 +107,7 @@
107 107
                     </property>
108 108
                     <property name="text">
109 109
                         <string>&lt;p&gt;&lt;b&gt;%1&lt;/b&gt; is an encrypted storage device.&lt;/p&gt;
110
-&lt;p&gt;Please enter the password to decrypt the storage device.&lt;/p&gt;</string>
110
+&lt;p&gt;Please enter the password to unlock/decrypt the storage device.&lt;/p&gt;</string>
111 111
                     </property>
112 112
                     <property name="alignment">
113 113
                         <set>WordBreak|AlignTop</set>

+ 111
- 88
tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp View File

@@ -45,16 +45,16 @@ const Medium MountHelper::findMedium(const KURL &url)
45 45
 	DCOPRef mediamanager("kded", "mediamanager");
46 46
 
47 47
 	// Try filename first
48
-	DCOPReply reply = mediamanager.call( "properties", url.fileName() );
49
-	if ( !reply.isValid() ) {
48
+	DCOPReply reply = mediamanager.call("properties", url.fileName());
49
+	if (!reply.isValid()) {
50 50
 		m_errorStr = i18n("The TDE mediamanager is not running.")+"\n";
51 51
 		return Medium(TQString::null, TQString::null, TQString::null);
52 52
 	}
53 53
 	const Medium& medium = Medium::create(reply);
54
-	if ( medium.id().isEmpty() ) {
54
+	if (medium.id().isEmpty()) {
55 55
 		// Try full URL now
56
-		reply = mediamanager.call( "properties", url.prettyURL() );
57
-		if ( !reply.isValid() ) {
56
+		reply = mediamanager.call("properties", url.prettyURL());
57
+		if (!reply.isValid()) {
58 58
 			m_errorStr = i18n("Internal Error");
59 59
 			return Medium(TQString::null, TQString::null, TQString::null);
60 60
 		}
@@ -72,20 +72,19 @@ MountHelper::MountHelper() : TDEApplication()
72 72
 
73 73
 	KURL url(args->url(0));
74 74
 	const Medium medium = findMedium(url);
75
-
76 75
 	if (medium.id().isEmpty())
77 76
 	{
78 77
 		if (m_errorStr.isEmpty()) {
79 78
 			m_errorStr+= i18n("%1 cannot be found.").arg(url.prettyURL());
80 79
 		}
81
-		TQTimer::singleShot(0, this, TQT_SLOT(error()) );
80
+		TQTimer::singleShot(0, this, TQT_SLOT(error()));
82 81
 		return;
83 82
 	}
84 83
 
85 84
 	if (!medium.isMountable() && !args->isSet("e") && !args->isSet("s"))
86 85
 	{
87 86
 		m_errorStr = i18n("%1 is not a mountable media.").arg(url.prettyURL());
88
-		TQTimer::singleShot(0, this, TQT_SLOT(error()) );
87
+		TQTimer::singleShot(0, this, TQT_SLOT(error()));
89 88
 		return;
90 89
 	}
91 90
 
@@ -94,18 +93,54 @@ MountHelper::MountHelper() : TDEApplication()
94 93
 
95 94
 	m_isCdrom = medium.mimeType().find("dvd") != -1 || medium.mimeType().find("cd") != -1;
96 95
 
97
-	if (args->isSet("d"))
96
+	if (args->isSet("m"))
97
+	{
98
+		// Mount drive
99
+		DCOPRef mediamanager("kded", "mediamanager");
100
+		DCOPReply reply = mediamanager.call("mount", medium.id());
101
+		TQStringVariantMap mountResult;
102
+		if (reply.isValid()) {
103
+			reply.get(mountResult);
104
+		}
105
+		if (mountResult.contains("result") && mountResult["result"].toBool()) {
106
+			::exit(0);
107
+		}
108
+		else {
109
+			m_errorStr = mountResult.contains("errStr") ? mountResult["errStr"].toString() : i18n("Unknown mount error.");
110
+			TQTimer::singleShot(0, this, TQT_SLOT(error()));
111
+		}
112
+	}
113
+	else if (args->isSet("u"))
98 114
 	{
115
+		// Unmount drive
116
+		DCOPRef mediamanager("kded", "mediamanager");
117
+		DCOPReply reply = mediamanager.call("unmount", medium.id());
118
+		TQStringVariantMap unmountResult;
119
+		if (reply.isValid()) {
120
+			reply.get(unmountResult);
121
+		}
122
+		if (unmountResult.contains("result") && unmountResult["result"].toBool()) {
123
+			::exit(0);
124
+		}
125
+		else {
126
+			m_errorStr = unmountResult.contains("errStr") ? unmountResult["errStr"].toString() : i18n("Unknown unmount error.");
127
+			kdDebug() << "medium unmount " << m_errorStr << endl;
128
+			TQTimer::singleShot(0, this, TQT_SLOT(error()));
129
+		}
130
+	}
131
+	else if (args->isSet("k"))
132
+	{
133
+		// Unlock drive
99 134
 		if (!medium.isEncrypted())
100 135
 		{
101 136
 			m_errorStr = i18n("%1 is not an encrypted media.").arg(url.prettyURL());
102
-			TQTimer::singleShot(0, this, TQT_SLOT(error()) );
137
+			TQTimer::singleShot(0, this, TQT_SLOT(error()));
103 138
 			return;
104 139
 		}
105 140
 		if (!medium.needDecryption())
106 141
 		{
107 142
 			m_errorStr = i18n("%1 is already decrypted.").arg(url.prettyURL());
108
-			TQTimer::singleShot(0, this, TQT_SLOT(error()) );
143
+			TQTimer::singleShot(0, this, TQT_SLOT(error()));
109 144
 			return;
110 145
 		}
111 146
 
@@ -115,34 +150,38 @@ MountHelper::MountHelper() : TDEApplication()
115 150
 			TQString mime = medium.mimeType();
116 151
 			iconName = KMimeType::mimeType(mime)->icon(mime, false);
117 152
 		}
118
-
119 153
 		m_mediumId = medium.id();
120 154
 		dialog = new Dialog(url.prettyURL(), iconName);
155
+		connect(dialog, TQT_SIGNAL(user1Clicked()), this, TQT_SLOT(slotSendPassword()));
156
+		connect(dialog, TQT_SIGNAL(cancelClicked()), this, TQT_SLOT(slotCancel()));
157
+		connect(this, TQT_SIGNAL(signalPasswordError(TQString)), dialog, TQT_SLOT(slotDialogError(TQString)));
121 158
 		dialog->show();
122
-
123
-		connect(dialog, TQT_SIGNAL (user1Clicked()), this, TQT_SLOT (slotSendPassword()));
124
-		connect(dialog, TQT_SIGNAL (cancelClicked()), this, TQT_SLOT (slotCancel()));
125
-		connect(this, TQT_SIGNAL (signalPasswordError(TQString)), dialog, TQT_SLOT (slotDialogError(TQString)));
126 159
 	}
127
-	else if (args->isSet("u"))
160
+	else if (args->isSet("l"))
128 161
 	{
129
-	  DCOPRef mediamanager("kded", "mediamanager");
130
-	  DCOPReply reply = mediamanager.call("unmount", medium.id());
131
-	  TQStringVariantMap unmountResult;
132
-	  if (reply.isValid()) {
133
-	    reply.get(unmountResult);
134
-    }
135
-	  if (unmountResult.contains("result") && unmountResult["result"].toBool()) {
162
+		// Lock drive
163
+		DCOPRef mediamanager("kded", "mediamanager");
164
+		DCOPReply reply = mediamanager.call("lock", medium.id());
165
+		TQStringVariantMap lockResult;
166
+		if (reply.isValid()) {
167
+			reply.get(lockResult);
168
+		}
169
+		if (lockResult.contains("result") && lockResult["result"].toBool()) {
136 170
 	    ::exit(0);
137 171
 	  }
138 172
 	  else {
139
-			m_errorStr = unmountResult.contains("errStr") ? unmountResult["errStr"].toString() : i18n("Unknown unmount error.");
140
-		  kdDebug() << "medium unmount " << m_errorStr << endl;
141
-	    error();
142
-	  }
173
+			m_errorStr = lockResult.contains("errStr") ? lockResult["errStr"].toString() : i18n("Unknown lock error.");
174
+			kdDebug() << "medium lock " << m_errorStr << endl;
175
+			TQTimer::singleShot(0, this, TQT_SLOT(error()));
176
+		}
143 177
 	}
144
-	else if (args->isSet("s") || args->isSet("e"))
178
+	else if (args->isSet("e"))
145 179
 	{
180
+		invokeEject(device, true);
181
+	}
182
+	else if (args->isSet("s"))
183
+	{
184
+		// Safely remove drive
146 185
 		DCOPRef mediamanager("kded", "mediamanager");
147 186
 
148 187
 		/*
@@ -154,54 +193,42 @@ MountHelper::MountHelper() : TDEApplication()
154 193
 		* anyway. Only if both unmount and eject fail, notify the user by
155 194
 		* displaying the saved error message (see ejectFinished()).
156 195
 		*/
196
+		TQStringVariantMap unmountResult;
157 197
 		if (medium.isMounted())
158 198
 		{
159
-			DCOPReply reply = mediamanager.call( "unmount", medium.id());
199
+			DCOPReply reply = mediamanager.call("unmount", medium.id());
160 200
 			if (reply.isValid()) {
161
-			  TQStringVariantMap unmountResult;
162 201
 				reply.get(unmountResult);
163
-				if (unmountResult["result"].toBool()) {
164
-					reply.get(m_errorStr);
202
+				if (unmountResult.contains("result") && !unmountResult["result"].toBool()) {
203
+					m_errorStr = unmountResult.contains("errStr") ? unmountResult["errStr"].toString() : i18n("Unknown unmount error.");
165 204
 				}
166 205
 			}
167 206
 		}
168 207
 
169
-		/* If this is a decrypted volume and there is no error yet
170
-		 * we try to teardown the decryption */
171
-		if (m_errorStr.isNull() && medium.isEncrypted() && !medium.clearDeviceUdi().isNull())
208
+		// If this is a decrypted volume and there is no error yet, we try to teardown the decryption
209
+		if (unmountResult.contains("result") && unmountResult["result"].toBool() &&
210
+		    medium.isEncrypted() && !medium.clearDeviceUdi().isNull())
172 211
 		{
173
-			DCOPReply reply = mediamanager.call( "undecrypt", medium.id());
212
+			DCOPReply reply = mediamanager.call("lock", medium.id());
174 213
 			if (reply.isValid()) {
175
-			  TQStringVariantMap undecryptResult;
176
-				reply.get(undecryptResult);
177
-				if (undecryptResult["result"].toBool()) {
178
-					reply.get(m_errorStr);
214
+				TQStringVariantMap lockResult;
215
+				reply.get(lockResult);
216
+				if (lockResult.contains("result") && !lockResult["result"].toBool()) {
217
+					m_errorStr = lockResult.contains("errStr") ? lockResult["errStr"].toString() : i18n("Unknown lock error.");
179 218
 				}
180 219
 			}
181 220
 		}
182 221
 
183
-		if (m_errorStr.isNull()) {
222
+		if (m_errorStr.isEmpty()) {
184 223
 			invokeEject(device, true);
185 224
 		}
186 225
 		else {
187
-			error();
226
+			TQTimer::singleShot(0, this, TQT_SLOT(error()));
188 227
 		}
189 228
 	}
190 229
 	else
191 230
 	{
192
-	  DCOPRef mediamanager("kded", "mediamanager");
193
-	  DCOPReply reply = mediamanager.call("mount", medium.id());
194
-	  TQStringVariantMap mountResult;
195
-	  if (reply.isValid()) {
196
-	    reply.get(mountResult);
197
-	  }
198
-	  if (mountResult.contains("result") && mountResult["result"].toBool()) {
199
-	    ::exit(0);
200
-	  }
201
-	  else {
202
-			m_errorStr = mountResult.contains("errStr") ? mountResult["errStr"].toString() : i18n("Unknown mount error.");
203
-	    error();
204
-	  }
231
+		TDECmdLineArgs::usage();
205 232
 	}
206 233
 }
207 234
 
@@ -212,7 +239,7 @@ void MountHelper::invokeEject(const TQString &device, bool quiet)
212 239
 	TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
213 240
 	TDEGenericDevice *hwdevice = hwdevices->findByDeviceNode(device);
214 241
 	if (hwdevice->type() == TDEGenericDeviceType::Disk) {
215
-		TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(hwdevice);
242
+		TDEStorageDevice *sdevice = static_cast<TDEStorageDevice*>(hwdevice);
216 243
 		if (sdevice->ejectDrive()) {
217 244
 			// Success!
218 245
 			::exit(0);
@@ -228,28 +255,21 @@ void MountHelper::invokeEject(const TQString &device, bool quiet)
228 255
 		*proc << "-q";
229 256
 	}
230 257
 	*proc << device;
231
-	connect( proc, TQT_SIGNAL(processExited(TDEProcess *)),
232
-		this, TQT_SLOT( ejectFinished(TDEProcess *) ) );
258
+	connect(proc, TQT_SIGNAL(processExited(TDEProcess*)),	this, TQT_SLOT(ejectFinished(TDEProcess*)));
233 259
 	proc->start();
234 260
 }
235 261
 
236
-void MountHelper::ejectFinished(TDEProcess* proc)
262
+void MountHelper::ejectFinished(TDEProcess *proc)
237 263
 {
238
-	/*
239
-	* If eject failed, report the error stored in m_errorStr
240
-	*/
264
+	//If eject failed, report the error stored in m_errorStr
241 265
 	if (proc->normalExit() && proc->exitStatus() == 0) {
242 266
 		::exit(0);
243
-	} else {
244
-		if (m_errorStr.isEmpty()) {
245
-			if (m_isCdrom)
246
-				m_errorStr = i18n("The device was successfully unmounted, but the tray could not be opened");
247
-			else
248
-				m_errorStr = i18n("The device was successfully unmounted, but could not be ejected");
267
+	}
268
+	else {
269
+		if (!m_errorStr.isEmpty()) {
270
+			TQTimer::singleShot(0, this, TQT_SLOT(error()));
249 271
 		}
250
-//X Comment this because the error is useless as long as the unmount is successful.
251
-//X 		TQTimer::singleShot(0, this, TQT_SLOT(error()));
252
-      ::exit(0);
272
+		::exit(0);
253 273
 	}
254 274
 }
255 275
 
@@ -269,19 +289,19 @@ void MountHelper::slotSendPassword()
269 289
 {
270 290
 	DCOPRef mediamanager("kded", "mediamanager");
271 291
 
272
-	DCOPReply reply = mediamanager.call( "decrypt", m_mediumId, dialog->getPassword() );
273
-	TQStringVariantMap decryptResult;
292
+	DCOPReply reply = mediamanager.call("unlock", m_mediumId, dialog->getPassword());
293
+	TQStringVariantMap unlockResult;
274 294
 	if (reply.isValid()) {
275
-		reply.get(decryptResult);
295
+		reply.get(unlockResult);
276 296
 	}
277
-	if (decryptResult.contains("result") && decryptResult["result"].toBool()) {
297
+	if (unlockResult.contains("result") && unlockResult["result"].toBool()) {
278 298
 		::exit(0);
279 299
 	}
280 300
 	else {
281
-		m_errorStr = decryptResult.contains("errStr") ? decryptResult["errStr"].toString() : i18n("Unknown decrypt error.");
282
-		kdDebug() << "medium decrypt " << m_errorStr << endl;
301
+		m_errorStr = unlockResult.contains("errStr") ? unlockResult["errStr"].toString() : i18n("Unknown unlock error.");
302
+		kdDebug() << "medium unlock " << m_errorStr << endl;
283 303
 		emit signalPasswordError(m_errorStr);
284
-		error();
304
+		TQTimer::singleShot(0, this, TQT_SLOT(error()));
285 305
 	}
286 306
 }
287 307
 
@@ -292,12 +312,13 @@ void MountHelper::slotCancel()
292 312
 
293 313
 static TDECmdLineOptions options[] =
294 314
 {
295
-	{ "d", I18N_NOOP("Decrypt given URL"), 0 },
315
+	{ "m", I18N_NOOP("Mount given URL"), 0 },
296 316
 	{ "u", I18N_NOOP("Unmount given URL"), 0 },
297
-	{ "m", I18N_NOOP("Mount given URL (default)"), 0 },
298
-	{ "e", I18N_NOOP("Eject given URL via tdeeject"), 0},
299
-	{ "s", I18N_NOOP("Unmount and Eject given URL (necessary for some USB devices)"), 0},
300
-	{"!+URL",   I18N_NOOP("media:/ URL to mount/unmount/eject/remove"), 0 },
317
+	{ "k", I18N_NOOP("Unlock given URL"), 0 },
318
+	{ "l", I18N_NOOP("Lock given URL"), 0 },
319
+	{ "e", I18N_NOOP("Eject given URL"), 0},
320
+	{ "s", I18N_NOOP("Safely remove (unmount and eject) given URL"), 0},
321
+	{"!+URL", I18N_NOOP("media:/URL to mount/unmount/unlock/lock/eject/remove"), 0 },
301 322
 	TDECmdLineLastOption
302 323
 };
303 324
 
@@ -308,13 +329,15 @@ int main(int argc, char **argv)
308 329
 	                   "tdeio_media_mounthelper", "tdeio_media_mounthelper",
309 330
 	                   "0.1");
310 331
 
311
-	TDECmdLineArgs::addCmdLineOptions( options );
332
+	TDECmdLineArgs::addCmdLineOptions(options);
312 333
 	TDEGlobal::locale()->setMainCatalogue("tdeio_media");
313 334
 	TDEApplication::addCmdLineOptions();
335
+	if (TDECmdLineArgs::parsedArgs()->count()==0)
336
+	{
337
+		TDECmdLineArgs::usage();
338
+	}
314 339
 
315
-	if (TDECmdLineArgs::parsedArgs()->count()==0) TDECmdLineArgs::usage();
316
-	TDEApplication *app = new  MountHelper();
317
-
340
+	TDEApplication *app = new MountHelper();
318 341
 	TDEStartupInfo::appStarted();
319 342
 	app->dcopClient()->attach();
320 343
 	return app->exec();

+ 2
- 1
tdeioslave/media/services/CMakeLists.txt View File

@@ -12,6 +12,7 @@
12 12
 ##### other data ################################
13 13
 
14 14
 install( FILES
15
-    media_decrypt.desktop media_mount.desktop media_unmount.desktop
15
+    media_mount.desktop media_unmount.desktop
16
+    media_unlock.desktop media_lock.desktop
16 17
     media_eject.desktop media_safelyremove.desktop
17 18
   DESTINATION ${DATA_INSTALL_DIR}/konqueror/servicemenus )

+ 1
- 1
tdeioslave/media/services/Makefile.am View File

@@ -1,3 +1,3 @@
1 1
 servicesdir = $(kde_datadir)/konqueror/servicemenus
2
-services_DATA = media_decrypt.desktop media_mount.desktop media_unmount.desktop media_eject.desktop media_safelyremove.desktop
2
+services_DATA = media_mount.desktop media_unmount.desktop media_unlock.desktop media_lock.desktop media_eject.desktop media_safelyremove.desktop
3 3
 

+ 10
- 0
tdeioslave/media/services/media_lock.desktop View File

@@ -0,0 +1,10 @@
1
+[Desktop Entry]
2
+X-TDE-ServiceTypes=media/removable_unmounted_decrypted,media/hdd_unmounted_decrypted,media/cdrom_unmounted_decrypted,media/cdwriter_unmounted_decrypted,media/dvd_unmounted_decrypted
3
+Actions=MediaLock;
4
+X-TDE-MediaNotifierHide=true
5
+
6
+[Desktop Action MediaLock]
7
+Exec=tdeio_media_mounthelper -l %u
8
+Icon=decrypted
9
+Name=Lock
10
+

tdeioslave/media/services/media_decrypt.desktop → tdeioslave/media/services/media_unlock.desktop View File

@@ -1,9 +1,10 @@
1
-[Desktop Action Decrypt]
2
-Exec=tdeio_media_mounthelper -d %u
3
-Icon=decrypted
4
-Name=Decrypt
5
-Name[de]=Entschlüsseln
6
-
7 1
 [Desktop Entry]
8
-Actions=Decrypt
9 2
 X-TDE-ServiceTypes=media/removable_unmounted_encrypted,media/hdd_unmounted_encrypted,media/cdrom_unmounted_encrypted,media/cdwriter_unmounted_encrypted,media/dvd_unmounted_encrypted
3
+Actions=MediaUnlock;
4
+X-TDE-MediaNotifierHide=true
5
+
6
+[Desktop Action MediaUnlock]
7
+Exec=tdeio_media_mounthelper -k %u
8
+Icon=decrypted
9
+Name=Unlock
10
+Name[de]=Entschlüsseln

Loading…
Cancel
Save